Home

Awesome

tiny_sqlite CI

tiny_sqlite is a comparatively thin wrapper for the SQLite database library. It differs from the standard library module std/db_sqlite in several ways:

Installation

tiny_sqlite is available on Nimble:

nimble install tiny_sqlite

Usage

import tiny_sqlite, std / options

let db = openDatabase(":memory:")
db.execScript("""
CREATE TABLE Person(
    name TEXT,
    age INTEGER
);

INSERT INTO
    Person(name, age)
VALUES
    ("John Doe", 47);
""")

db.exec("INSERT INTO Person VALUES(?, ?)", "Jane Doe", nil)

for row in db.iterate("SELECT name, age FROM Person"):
    let (name, age) = row.unpack((string, Option[int]))
    echo name, " ", age

# Output:
# John Doe Some(47)
# Jane Doe None[int]

Documentation