I’m new to OCaml and interested in using Petrol to interact with an sqlite3 database. To start things out, I’m trying to run the first example in the Petrol readme.md. In particular, I want to build the code:
open Petrol
open Petrol.Sqlite3(* define a new schema *)
let schema = StaticSchema.init ()(* declare a table *)
let example_table, Expr.[name; age] =
StaticSchema.declare_table schema ~name:“example”
Schema.[
field “name” ~ty:Type.text;
field “age” ~ty:Type.int
]
which I put in the file test1.ml.
First, I install Petrol with:
opam install petrol
I have a dune file which contains
(executable
(name test1)
(libraries petrol))
When I run
dune build test1.exe
I get the error:
File “test1.ml”, line 2, characters 5-19:
2 | open Petrol.Sqlite3
^^^^^^^^^^^^^^
Error: Unbound module Petrol.Sqlite3
So it appears that the line for
open Petrol
worked fine, but it didn’t know how to find Petrol.Sqlite3 which is opened in the next line.
I’ve tried to do
opam install petrol.sqlite3
and
opam install petrol.Sqlite3
which don’t work because it returns an error, “Package petrol has no version sqlite3.” or “Package petrol has no version Sqlite3.”
I tried modifying the dune file to
(executable
(name test1)
(libraries petrol petrol.sqlite3))
(and the same modification with a capital S for Sqlite3) but I get “Error: Library “petrol.sqlite3” not found.” or “Error: Library “petrol.Sqlite3” not found.”
I’m not sure where to go from here to get this working. Any help would be appreciated!
3 posts - 2 participants