Skip to content
/ sqlite3 Public
forked from janet-lang/sqlite3

Bindings to sqlite for the Janet language.

License

Notifications You must be signed in to change notification settings

tionis/sqlite3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLite bindings

This native module proves sqlite bindings for janet.

Install

jpm install sqlite3

Building

To build, use the jpm tool and make sure you have janet installed.

jpm build

Using the System's SQLite library

Usually, a Linux system has a package for SQLite installed globally. This packages will usually have many plugins for SQlite enabled (e.g JSON1, FTS3 etc.). The Debian package or Gentoo ebuild are good examples.

This package allows one to use it instead of the SQLite sources included with the package. To do this use:

export JANET_SYSTEM_SQLITE=1
jpm build

Note, if you intead to install the package globally, use:

sudo -E jpm build

Update the embedded SQLite version

You can use the jpm rule to update the version of SQLite included.

jpm run update-sqlite3

You can find the latest version https://sqlite.org/index.html.

Example Usage

Next, enter the repl and create a database and a table. By default, the generated module will be in the build folder.

janet:1:> (import build/sqlite3 :as sql)
nil
janet:2:> (def db (sql/open "test.db"))
<sqlite3.connection 0x5561A138C470>
janet:3:> (sql/eval db `CREATE TABLE customers(id INTEGER PRIMARY KEY, name TEXT);`)
@[]
janet:4:> (sql/eval db `INSERT INTO customers VALUES(:id, :name);` {:name "John" :id 12345})
@[]
janet:5:> (sql/eval db `SELECT * FROM customers;`)
@[{"id" 12345 "name" "John"}]

Finally, close the database connection when done with it.

janet:6:> (sql/close db)
nil

About

Bindings to sqlite for the Janet language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%