{"id":13726231,"url":"https://github.com/paurkedal/ocaml-caqti","last_synced_at":"2025-05-16T04:06:16.554Z","repository":{"id":15154637,"uuid":"17882175","full_name":"paurkedal/ocaml-caqti","owner":"paurkedal","description":"Cooperative-threaded access to relational data","archived":false,"fork":false,"pushed_at":"2025-03-30T08:26:02.000Z","size":3092,"stargazers_count":318,"open_issues_count":8,"forks_count":39,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-08T14:11:21.301Z","etag":null,"topics":["async","database","io-monad","lwt","mariadb","ocaml","postgresql","sqlite"],"latest_commit_sha":null,"homepage":"https://paurkedal.github.io/ocaml-caqti/index.html","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paurkedal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-18T21:11:08.000Z","updated_at":"2025-04-05T20:38:43.000Z","dependencies_parsed_at":"2023-12-15T17:23:03.067Z","dependency_job_id":"3963c6c5-c36a-4dc2-bcdf-f6b7693c99ac","html_url":"https://github.com/paurkedal/ocaml-caqti","commit_stats":{"total_commits":885,"total_committers":21,"mean_commits":"42.142857142857146","dds":0.3016949152542373,"last_synced_commit":"ed71ade26c0e8efd88039321da2419a0c9523bda"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Focaml-caqti","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Focaml-caqti/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Focaml-caqti/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Focaml-caqti/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paurkedal","download_url":"https://codeload.github.com/paurkedal/ocaml-caqti/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464895,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","database","io-monad","lwt","mariadb","ocaml","postgresql","sqlite"],"created_at":"2024-08-03T01:02:56.445Z","updated_at":"2025-05-16T04:06:11.545Z","avatar_url":"https://github.com/paurkedal.png","language":"OCaml","funding_links":[],"categories":["Databases","OCaml"],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/paurkedal/ocaml-caqti.svg?style=svg)](https://circleci.com/gh/paurkedal/ocaml-caqti)\n\n## Synopsis\n\nCaqti provides a monadic cooperative-threaded OCaml connector API for\nrelational databases.\n\nThe purpose of Caqti is further to help make applications independent of a\nparticular database system.  This is achieved by defining a common\nsignature, which is implemented by the database drivers.  Connection\nparameters are specified as an URI, which is typically provided at run-time.\nCaqti then loads a driver which can handle the URI, and provides a\nfirst-class module which implements the driver API and additional\nconvenience functionality.\n\nCaqti does not generate or analyze SQL but provides templating and uniform\nquery parameter handling, including encoding and decoding data according to\ndeclared types.  It is hoped that this agnostic choice makes it a suitable\ntarget for higher level interfaces and code generators.\n\nThe following drivers are available:\n\nRDBMS      | URI scheme      | library        | Unix | MirageOS\n---------- | --------------- | -------------- | ---- | --------\nMariaDB    | `mariadb://`    | [mariadb][]    | yes  | no\nPostgreSQL | `postgresql://` | [postgresql][] | yes  | no\nPostgreSQL | `pgx://`        | [pgx][]        | yes  | yes\nSQLite3    | `sqlite3://`    | [sqlite3][]    | yes  | no\n\nThe PGX based driver is experimental and only recommended for MirageOS.\nMore about the drivers below.\n\n## Documentation\n\n### Tutorials and Examples\n\n  - The [caqti-study][] repository is a tutorial with examples, which we\n    will keep up to date with the latest release of Caqti.  It is work in\n    progress; suggestions and contributions are welcome.\n  - [Interfacing OCaml and PostgreSQL with Caqti][BP-2018] by Bobby\n    Priambodo gives a gentle introduction, though the Caqti API has changed\n    to some extend since it was written.\n  - [The documented example][bikereg] in this repository can give a first\n    idea.\n\n### API Documentation for Stable Releases\n\nThe stable API documentation is hosted on [https://ocaml.org](), where you\ncan search package by name.\n\nA full Caqti release contains the following packages:\n\n  - [caqti](https://ocaml.org/p/caqti/latest):\n    Core libraries and blocking unix connector.\n  - [caqti-lwt](https://ocaml.org/p/caqti-lwt/latest):\n    Lwt support library and connector.\n  - [caqti-async](https://ocaml.org/p/caqti-async/latest):\n    Async connector.\n  - [caqti-eio](https://ocaml.org/p/caqti-eio/latest):\n    Experimental EIO connector.\n  - [caqti-miou](https://ocaml.org/p/caqti-miou/latest):\n    Experimental Miou connector.\n  - [caqti-mirage](https://ocaml.org/p/caqti-mirage/latest):\n    Experimental MirageOS connector.\n  - [caqti-driver-mariadb](https://ocaml.org/p/caqti-driver-mariadb):\n    Driver for MariaDB and MySQL using C bindings from [mariadb][].\n  - [caqti-driver-postgresql](https://ocaml.org/p/caqti-driver-postgresql):\n    Driver for PostgreSQL using C bindings from [postgresql][].\n  - [caqti-driver-sqlite3](https://ocaml.org/p/caqti-driver-sqlite3):\n    Driver for local SQlite3 databases using C bindings from [sqlite3][].\n  - [caqti-driver-pgx](https://ocaml.org/p/caqti-driver-pgx):\n    Experimental driver for PostgreSQL using the [pgx][] library.\n  - [caqti-tls](https://ocaml.org/p/caqti-tls):\n    TLS configuration currently only used by caqti-mirage, and only relevant\n    for pgx, since drivers based on C bindings have external TLS support.\n\nThe connector modules provide a connect functions which receives an URI,\ndispatches to an appropriate driver, and returns a connection object as a\nfirst-class module, which contains query functionality for the database.\nThe application can either link against the drivers it needs or the link\nagainst the `caqti.plugin` library in order to load the appropriate driver\nat runtime.\n\n(A few package not mentioned include unreleased TLS packages and the\nsemi-deprecated packages\n[caqti-type-calendar](https://ocaml.org/p/caqti-type-calendar/latest) and\n[caqti-dynload](https://ocaml.org/p/caqti-dynload/latest).)\n\n### API Documentation for Development Snapshots\n\nApart from the above links, the [GitHub pages][caqti-ghpages] are updated\noccasionally with a rendering from the master branch.  You can also build\nthe API reference matching your installed version using [odig][] or run\n`dune build @doc` in a Git checkout.\n\n## Running under utop\n\nDynamic linking does not work under utop.  The workaround is to link against\nthe needed database driver.  E.g.\n```ocaml\n# #require \"caqti-lwt\";;\n# #require \"caqti-driver-postgresql\";;\n# open Lwt.Infix;;\n# open Caqti_request.Infix;;\n\n(* Create a DB handle. *)\n# module Db = (val Caqti_lwt_unix.connect (Uri.of_string \"postgresql://\") \u003e\u003e= Caqti_lwt.or_fail |\u003e Lwt_main.run);;\nmodule Db : Caqti_lwt.CONNECTION\n\n(* Create a request which merely adds two parameters. *)\n# let plus = Caqti_request.(Caqti_type.(t2 int int) -\u003e! Caqti_type.int) \"SELECT ? + ?\";;\nval plus : (int * int, int, [\u003c `Many | `One | `Zero \u003e `One ]) Caqti_request.t =\n  \u003cabstr\u003e\n\n(* Run it. *)\n# Db.find plus (7, 13);;\n- : (int, [\u003e Caqti_error.call_or_retrieve ]) result = Ok 20\n```\n\n## Related Software\n\n  - [ppx\\_rapper](https://github.com/roddyyaga/ppx_rapper) - a syntax\n    extension for Caqti queries, simplifying type specifications.\n\n## Sponsor\n\n\u003ca href=\"https://ocaml-sf.org\"\u003e\n\u003cimg align=\"left\" alt=\"OCSF logo\" src=\"https://ocaml-sf.org/assets/ocsf_logo.svg\"/\u003e\n\u003c/a\u003e\nThanks to the \u003ca href=\"https://ocaml-sf.org\"\u003eOCaml Software Foundation\u003c/a\u003e\nfor economic support to the development of Caqti.\n\n\n[caqti-ghpages]: http://paurkedal.github.io/ocaml-caqti/index.html\n[BP-2018]: https://medium.com/@bobbypriambodo/interfacing-ocaml-and-postgresql-with-caqti-a92515bdaa11\n[bikereg]: examples/bikereg.ml\n[caqti-study]: https://github.com/paurkedal/caqti-study/\n[odig]: http://erratique.ch/software/odig\n[mariadb]: https://github.com/andrenth/ocaml-mariadb\n[pgx]: https://github.com/arenadotio/pgx\n[postgresql]: https://mmottl.github.io/postgresql-ocaml\n[sqlite3]: https://mmottl.github.io/sqlite3-ocaml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaurkedal%2Focaml-caqti","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaurkedal%2Focaml-caqti","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaurkedal%2Focaml-caqti/lists"}