package pgx_lwt_unix

  1. Overview
  2. Docs
Pgx using Lwt and Unix libraries for IO

Install

Dune Dependency

Authors

Maintainers

Sources

pgx_lwt_mirage-2.0.tbz
sha256=be6bac83e4030b6225f3966fd482b242818ff1147efc273163d4a9cd749b62bd
sha512=c18e3b7d246f184c5a689d081f613937d569f9b794b95e586c5c16ddb7402581049642dd20852ec95316c4681b70f5e8f494fc9475adecf64d53b13d70257c98

Description

Pgx using Lwt and Unix libraries for IO

Published: 14 May 2021

README

README.md

PGX is a pure-OCaml PostgreSQL client library, supporting Async, LWT, or synchronous operations.

This library focuses on correctness and safety, with features like:

  • It is nearly impossible to try to execute a prepared statement that hasn't been prepared.

  • Trying to run multiple queries at the same time will work properly (although there's no performance benefit, since we currently don't send queries in parallel).

  • Lots of automated tests.

  • Pgx.Value for parameters and returned data, encouraging people to use the built-in converters instead of trying to handle everything as a string.

  • Async and LWT support are built in, no need to write your own IO module.

  • Mirage OS is supported via Pgx_lwt_mirage

We also provide a relatively high-level interface, like Pgx_async.execute_pipe, which prepares a statement, executes it with the given parameters, returns an Async.Pipe.Reader.t (so you can stream results), and unprepares the statement when the query is finished.

Significant portions of the code come from PG'Ocaml.

Setup

opam install pgx_async # or pgx_lwt_unix or pgx_unix or pgx_lwt_mirage

Examples

See pgx_async/bin/pgx_async_example.ml for a complete example of the high-level functional interface. To translate the example to Lwt, replace Pgx_async with Pgx_lwt and >>| with >|=. To translate it to synchronous IO / standard-library-only, use Pgx_unix and replace both >>| and >>= with |>, or just replace >>| fun () -> with ;.

I.e. in Pgx_unix, you can replace:

Pgx_async.execute ~params "INSERT INTO ..."
>>| fun () ->

... with:

Pgx_unix.execute ~params "INSERT INTO ...";

Dependencies (4)

  1. pgx_lwt = version
  2. pgx = version
  3. ocaml >= "4.08"
  4. dune >= "1.11"

Dev Dependencies (2)

  1. base64 with-test & >= "3.0.0"
  2. alcotest-lwt with-test & >= "1.0.0"

Used by (1)

  1. omigrate

Conflicts

None

OCaml

Innovation. Community. Security.