No description
Find a file
PhilippMDoerner c8bd2c631e
Merge pull request #20 from PhilippMDoerner/bugfix/nimble-requires-fornim2
The nimble file failed to import db_connector for nim version 2.0
2023-08-06 12:48:54 +02:00
.github Testsuite refactor (#16) 2023-03-05 10:32:26 +01:00
src Enable more tests (#17) 2023-03-11 22:36:35 +01:00
tests Enable more tests (#17) 2023-03-11 22:36:35 +01:00
.gitignore Initial ndb/postgres draft 2019-09-03 21:18:01 +00:00
changelog.md Add version bump 2023-08-06 12:45:00 +02:00
docker-compose.yml Remove pointless book docker compose service 2023-02-10 21:07:57 +01:00
Dockerfile Add explicit statement of nim version 2023-02-10 19:54:01 +01:00
LICENSE.MIT Initial version 2018-09-29 18:35:16 +07:00
lowdb.nimble Add version bump 2023-08-06 12:45:00 +02:00
readme.md Add installation instructions to readme 2023-02-25 12:08:59 +01:00

lowdb

An ndb fork capable of working with nim 2.0

A fork of db_sqlite and db_postgres, Nim's database libraries for Sqlite and Postgres, based on ndb.

Warning: work in progress, API is a subject of change.

Installation

Install lowdb with Nimble:

$ nimble install -y lowdb

Add lowdb to your .nimble file:

requires "lowdb"

Features

General

  • No more empty strings as a default placeholder value. Empty string, NULL, and an absence of a row are distinguished.

SQLite:

  • 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.

Example

import lowdb/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()

lowdb/postgres

Initial PostgreSQL support is provided. It is not complete yet.

Why Fork ndb?

First up, we want to give a huge shoutout to the original author of the package, Albert Safin, who made this possible. We are thankful for the effort that went into this package and that has served us well over the years.

Now why did we decide to fork? We, the developers of norm, depend on this package and it staying up to date as well as adding more support of postgres features. This is particularly relevant for the (as of 09.02.2023 still upcoming) release of nim 2.0, which break this package and subsequently norm. Sadly, ndb appears to no longer be actively maintained and has become a bottleneck for developing norm.

As such we have decided to maintain our own fork of it, to be able to prepare norm for the upgrade to nim 2.0, the addition of asynchronous usage of postgres and maybe more in the future.