Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scull7/bs-sqlite
Bindings to the [better-sqlite3] module for interaction with Sqlite databases.
https://github.com/scull7/bs-sqlite
Last synced: about 1 month ago
JSON representation
Bindings to the [better-sqlite3] module for interaction with Sqlite databases.
- Host: GitHub
- URL: https://github.com/scull7/bs-sqlite
- Owner: scull7
- License: mit
- Created: 2018-03-03T06:57:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T10:42:01.000Z (almost 2 years ago)
- Last Synced: 2023-03-12T11:05:13.243Z (over 1 year ago)
- Language: OCaml
- Size: 236 KB
- Stars: 2
- Watchers: 3
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://www.travis-ci.org/scull7/bs-sqlite.svg?branch=master)](https://www.travis-ci.org/scull7/bs-sqlite)
[![Coverage Status](https://coveralls.io/repos/github/scull7/bs-sqlite/badge.svg?branch=master)](https://coveralls.io/github/scull7/bs-sqlite?branch=master)
[![NPM version](http://img.shields.io/npm/v/bs-sqlite.svg)](https://www.npmjs.org/package/bs-sqlite)# bs-sqlite
Bindings to the [better-sqlite3] module for interaction with Sqlite databases.## Usage
### Basic Select
```ocaml
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
)
```### Use un-named parameters
```ocaml
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
)
```### Use named parameters
#### Using :x format
```ocaml
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
)
```#### Using $x format
```ocaml
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
)
```#### Using @x format
```ocaml
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
)
```## How do I install it?
Inside of a BuckleScript project:
```shell
yarn add bs-sqlite
```Then add `bs-sqlite` to your `bs-dependencies` in `bsconfig.json`:
```json
{
"bs-dependencies": [ "bs-sqlite" ]
}
```[better-sqlite3]: https://github.com/JoshuaWise/better-sqlite3