ez_pgocaml

A simple library to work with pgocaml
README

ez_pgocaml : a simple library to work with pgocaml

Installation

To build:

opam pin .
opam install ez_pgocaml

Usage

A typical usage is to create a database migration tool for your application:

The file updater.ml contains:

let () =
  EzPGUpdater.main Versions.database Versions.versions

where versions.ml contains:

let database = "testdb"

let update_0_to_1 dbh =
  EzPG.exec dbh
      (Printf.sprintf "CREATE TABLE %s (%s)" 
      "users"
         {|
          user_id bigserial PRIMARY KEY,
          login VARCHAR NOT NULL,
          pwhash bytea NOT NULL
         |})

let update_1_to_2 dbh =
    EzPG.exec dbh
      (Printf.sprintf "CREATE TABLE %s (%s)" 
      "infos"
         {|
          user_id bigserial PRIMARY KEY,
          city VARCHAR
         |})

let versions = [
  0, update_0_to_1;
  1, update_1_to_2;
  ]

When ran, the corresponding executable will try to migrate the database
from any version to the latest (2 in this example).

Install
Published
30 Mar 2021
Sources
v1.0.tar.gz
sha256=57b409aeef2e0e5e372ba23d4ca40a5e62f5d85d3a69aeab301d0670da4a986c
Dependencies
pgocaml
>= "4.2.2"
dune
>= "2.0"
ocaml
>= "4.07.0"
Reverse Dependencies