I’m trying to get connected to a Postgres database and have been trying to get darioteixeira/pgocaml (
opam install pgocaml pgocaml_ppx) to work but I continue to have issues with it. Based on this post I pinned the dev version (
opam pin --dev pgocaml_ppx) with OCaml version 4.12.
Is there another Postgres library that is maybe a bit more maintained?
Any thoughts on how to get this working easily would be much appreciated.
When I execute a simple query it fails:
open PGOCaml let get_db_schema = let dbh = PGOCaml.connect () in let res = [%pgsql.object dbh "select table_schema, table_name from information_schema.columns where table_schema not in ('information_schema', 'pg_catalog') order by table_schema, table_name"] in let a = List.iter (fun row -> Printf.printf "%s makes $%f\n" row#table_schema row#table_name) res in PGOCaml.close dbh;
File "lib/db.ml", line 24, characters 31--660: Error: Unbound value name_of_string Hint: Did you mean date_of_string or time_of_string?
And if I follow the docs and try
let%lwt res = by adding
%lwt, the compiler doesn’t know anything about the extension:
15 | let%lwt res = ^^^ Error: Uninterpreted extension 'lwt'.