package ez_pgocaml

  1. Overview
  2. Docs
A simple library to work with pgocaml

Install

Dune Dependency

Authors

Maintainers

Sources

v1.0.tar.gz
sha256=57b409aeef2e0e5e372ba23d4ca40a5e62f5d85d3a69aeab301d0670da4a986c

Description

Published: 30 Mar 2021

README

README.md

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).

Dependencies (3)

  1. pgocaml >= "4.2.2"
  2. dune >= "2.0"
  3. ocaml >= "4.07.0"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.