Skip to content

gokr/harding-sqlite

Repository files navigation

Harding SQLite

SQLite database access for Harding.

This library packages both:

  • native Nim bindings using db_connector/db_sqlite
  • Harding classes under lib/sqlite/

It mirrors the packaging style of harding-mysql, but uses SQLite's local-file and in-memory database model.

Install In Harding

From a Harding checkout:

./harding lib install sqlite
nimble harding

If you cloned this library manually into external/sqlite, create the local metadata file first:

cp external/sqlite/.harding-lib.json.disabled external/sqlite/.harding-lib.json
nimble discover
nimble harding

Demo

Run the in-memory demo:

./harding external/sqlite/examples/smoke.hrd

Expected output is similar to:

Connected to SQLite
2
2
Grace => 1337
Ada => 1200

Testing

From a Harding checkout with this repo at external/sqlite:

cp external/sqlite/.harding-lib.json.disabled external/sqlite/.harding-lib.json
nimble discover
nimble harding
nim c -r --nimcache:nimcache/sqlite-lib-tests -o:external/sqlite/tests/sqlite_lib_tests -d:harding_sqlite external/sqlite/tests/test_sqlite.nim

The tests use SQLite's :memory: database, so no database server or fixture cleanup is required.

Harding Example

conn := SqliteConnection open: ":memory:".

conn execute: "CREATE TABLE players (name TEXT, score INTEGER)".
conn execute: "INSERT INTO players (name, score) VALUES ('Ada', 1200)".
conn execute: "INSERT INTO players (name, score) VALUES ('Grace', 1337)".

result := conn query: "SELECT name, score FROM players ORDER BY score DESC".
row := result next.
((row at: 0) , " => " , (row at: 1)) println.
row := result next.
((row at: 0) , " => " , (row at: 1)) println.

result close.
conn close.

About

SQLite database connectivity for Harding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages