ndb
A db_sqlite fork with a proper typing
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install ndb
choosenim install ndb
git clone https://github.com/xzfc/ndb.nim
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| ndb | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/xzfc/ndb.nim |
|---|---|
| Homepage | https://github.com/xzfc/ndb.nim |
| Registry Source | nimble_official |
README
ndb/sqlite
A fork of db_sqlite, Nim's standard library higher level SQLite database wrapper. Warning: work in progress, API is a subject of change.
Features
- Binding
?parameters is done with native SQlitesqlite3_bind_*functions instead of stringifying and then escaping every parameter. As a result: - In addition to
?, the?NNNsyntax is supported. See sqlite3_varparam. - Inserting binary blobs is handled in a proper way. See Nim#5768.
- It is possible to insert the
NULLvalue. - No more empty strings as a default placeholder value.
Empty string,
NULL, and an absence of a row are distinguished.
Example
import ndb/sqlite
let db = open(":memory:", "", "", "")
# Insert NULL
db.exec(sql"CREATE TABLE foo (a, b)")
db.exec(sql"INSERT INTO foo VALUES (?, ?)", 1, DbNull())
# Insert binary blob
db.exec(sql"CREATE TABLE blobs (a BLOB)")
db.exec(sql"INSERT INTO blobs VALUES (?)", DbBlob "\x00\x01\x02\x03")
let blobValue = db.getAllRows(sql"SELECT * FROM BLOBS")[0][0].b
db.close()
ndb/postgres
Initial PostgreSQL support is provided. It is not complete yet.
Roadmap
This approach can be extended to other db_* modules in a consistent way:
* db_mysql: use [mysql_stmt_bind_param], see Nim#5884.
* db_odbc: use [SQLBindParameter].