bnlang-sqlite
A lightweight, fast, and ergonomic SQlite client for Bnlang.
5 downloads
v1.0.0
Updated 27 days ago
License: MIT
README
bnlang-sqlite
A lightweight, fast, and ergonomic SQlite client for Bnlang (Bangla Programming Language).
It provides a simple API for connecting, running queries, transactions, and connection pooling—tailored for Bnlang apps and tools.
✨ Features
- Zero-config quick start
- Safe parameterized queries (prepared statements)
- Pooled and single connections
- Transactions with
begin → commit/rollback
- Streamed results for large datasets
- Typed helpers for common CRUD
- Graceful shutdown hooks
📦 Installation
Using BPM (Bnlang Package Manager):
bpm install bnlang-sqlite
Require in your Bnlang source:
ধ্রুবক sqlite = require("bnlang-sqlite");
⚙️ Configuration
Create a client by URL or by object.
ধ্রুবক sqlite = require("bnlang-sqlite");
ধ্রুবক conn = sqlite.createConnection({ file: "test.sqlite", debug: true });
🚀 Quick Start
"use strict";
ধ্রুবক conn = sqlite.createConnection({ file: "test.sqlite", debug: true });
(অসমলয় () => {
অপেক্ষা conn.connect();
চেষ্টা {
ধ্রুবক { rows } = অপেক্ষা conn.query("SELECT id, name, email FROM users");
লিখুন("All users:");
লিখুন(rows);
} ধরুন (err) {
console.error("Select error:", err);
} অবশেষে {
অপেক্ষা conn.end();
}
})();
🔐 Parameterized Queries
Always pass values separately to prevent SQL injection:
const user = await db.query(
"SELECT id, email FROM users WHERE email = ?",
["[email protected]"]
);
?
placeholders are replaced safely with encoded values.- For IN-lists, pass arrays and use helpers:
const ids = [1,2,3];
const rows = await db.query("SELECT * FROM orders WHERE id IN (?)", [ids]);
🤝 Contributing
Issues and PRs are welcome!
Please open an issue describing the change before sending a large PR.
- Ensure tests cover your change
- Keep the API minimal and consistent
- Follow the existing code style
License
bnlang-sqlite is licensed under the MIT License.