Giter VIP home page Giter VIP logo

pgx's Introduction

CircleCI Coverage Status

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

API documentation

This is an early release. The API is likely to change significantly before the 1.0 release.

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.

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 pin add pgx https://github.com/arenadotio/pgx.git

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

pgx's People

Contributors

brendanlong avatar vgrocha avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.