A Brief Introduction to PG'OCaml
I have been immersed in Ocsigen and PG'OCaml for the past few weeks. They are both really fun to use and very powerful! The latter, however, had very poor documentation, a fact that has recently become quite evident with the constant flow of questions about it in the OCaml-beginners mailing-list. I had written my own notes about this library some time ago, and now I decided to put them together into a coherent document and to make them public. The result is titled A Brief Introduction to PG'OCaml, and is available for download from my homepage (it is licensed under a Creative Commons Attribution-Share Alike 3.0 License). If you're curious and what to find out more, here's the summary of the document:
PG'OCaml, by Richard W. M. Jones, provides an interface to PostgreSQL databases for OCaml applications. It uses Camlp4 to extend the OCaml syntax, enabling one to directly embed SQL statements inside the OCaml code. Moreover, it uses the "describe" feature of PostgreSQL to obtain type information about the database. This allows PG'OCaml to check at compile-time if the programme is indeed consistent with the database structure. This type-safe database access is the primary advantage that PG'OCaml has over other PostgreSQL bindings for OCaml.
Unfortunately, PG'OCaml is rather lacking on the documentation front. This document aims to fill that gap, by providing an overview of the capabilities of the library, usage examples, and solutions to potential pitfalls. Moreover, it also addresses the installation of PG'OCaml, how to compile programmes that make use of the library, and the correspondence between PostgreSQL data types and their OCaml counterparts.

Comments