Skip to content

xzfc/ndb.nim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ndb/sqlite

Documentation Build Status License: MIT Version

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 SQlite sqlite3_bind_* functions instead of stringifying and then escaping every parameter. As a result:
    • In addition to ?, the ?NNN syntax is supported. See sqlite3_varparam.
    • Inserting binary blobs is handled in a proper way. See Nim#5768.
    • It is possible to insert the NULL value.
  • 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:

About

A db_sqlite fork with a proper typing

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages