Skip to content
/ pgx Public
forked from arenadotio/pgx

A pure OCaml PostgreSQL client library

License

Notifications You must be signed in to change notification settings

m-click/pgx

This branch is up to date with arenadotio/pgx:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2bdd518 · Oct 26, 2022
Feb 25, 2021
May 31, 2018
Oct 26, 2022
May 11, 2021
Jun 22, 2021
Mar 10, 2022
May 10, 2021
May 10, 2021
May 11, 2021
Jun 23, 2020
Jun 21, 2021
Mar 10, 2022
Dec 21, 2017
May 31, 2022
Apr 24, 2020
Dec 21, 2017
Apr 24, 2020
Oct 26, 2022
May 31, 2018
May 20, 2020
May 8, 2020
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
Oct 26, 2022
May 8, 2020

Repository files navigation

CircleCI Coverage Status Documentation

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 ...";

About

A pure OCaml PostgreSQL client library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • OCaml 97.2%
  • Standard ML 2.4%
  • Other 0.4%