Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/olliNiinivaara/SQLiteral
A higher level SQLite API
https://github.com/olliNiinivaara/SQLiteral
Last synced: 3 months ago
JSON representation
A higher level SQLite API
- Host: GitHub
- URL: https://github.com/olliNiinivaara/SQLiteral
- Owner: olliNiinivaara
- License: mit
- Created: 2020-04-14T16:27:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-19T16:39:17.000Z (about 1 year ago)
- Last Synced: 2024-05-18T14:34:20.503Z (6 months ago)
- Language: Nim
- Homepage:
- Size: 137 KB
- Stars: 49
- Watchers: 9
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nim - SQLiteral - A high level SQLite API for Nim. (Data / Database)
README
# SQLiteral
A high level SQLite API for NimSupports multi-threading, prepared statements, proper typing,
zero-copy data paths, debugging, JSON, optimizing, backups, and more...## Documentation
http://olliNiinivaara.github.io/SQLiteral/
## Installation
`atlas use sqliteral`
## 4.0.0 Release notes (2023-08-19)
* Compatibility with Nim 2
* Single-threaded mode is not supported anymore (breaking change)
* Avoid crashing from trying to get filesize of in-memory database in about
* Unlimited amount of threads supported
* New finalizeStatements proc (semi-breaking change)
* New interrupt proc
* Various minor performance and other fixes## Example
```nim
import sqliteral
const Schema = "CREATE TABLE IF NOT EXISTS Example(string TEXT NOT NULL)"
type SqlStatements = enum
Upsert = """INSERT INTO Example(rowid, string) VALUES(1, ?)
ON CONFLICT(rowid) DO UPDATE SET string = ?"""
SelectAll = "SELECT string FROM Example"
var db: SQLiteralproc operate(i: string) =
let view: DbValue = i.toDb(3, 7) # zero-copy view into string
db.transaction: db.exec(Upsert, view, view)
for row in db.rows(SelectAll): echo row.getCString(0)db.openDatabase("example.db", Schema)
db.prepareStatements(SqlStatements)
var input = "012INPUT89"
operate(input)
db.close()
```