Bindings to the better-sqlite3 module for interaction with Sqlite databases.
let db = Sqlite.Connection.make ~path:"test.db" ~memory:Js.true_ ()
let _ = Sqlite.Connection.prepare db "SELECT 1 + 1 AS result"
|> Sqlite.Statement.get [||]
|> Js.log
)
let db = Sqlite.Connection.make ~path:"test.db" ~memory:Js.true_ ()
let _ = Sqlite.Connection.prepare db "SELECT ? + ? AS result"
|> Sqlite.Statement.get [|1; 1|]
|> Js.log
)
let db = Sqlite.Connection.make ~path:"test.db" ~memory:Js.true_ ()
let _ = Sqlite.Connection.prepare db "SELECT :x + :y AS result"
|> Sqlite.Statement.get_named [%bs.obj { x = 1; y = 2 }]
|> Js.log
)
let db = Sqlite.Connection.make ~path:"test.db" ~memory:Js.true_ ()
let _ = Sqlite.Connection.prepare db "SELECT $x + $y AS result"
|> Sqlite.Statement.get_named [%bs.obj { x = 1; y = 2 }]
|> Js.log
)
let db = Sqlite.Connection.make ~path:"test.db" ~memory:Js.true_ ()
let _ = Sqlite.Connection.prepare db "SELECT @x + @y AS result"
|> Sqlite.Statement.get_named [%bs.obj { x = 1; y = 2 }]
|> Js.log
)
Inside of a BuckleScript project:
yarn install --save bs-sqlite
Then add bs-sqlite
to your bs-dependencies
in bsconfig.json
:
{
"bs-dependencies": [ "bs-sqlite" ]
}