#afot #OverDriveDb #InCodeSDK #EmbeddedDB
What is OverDrive?
OverDrive is an embeddable, zero-config document database for Rust, Python, Node.js, and C/C++. It stores JSON documents, supports SQL queries, full-text search, secondary indexing, and ACID transactions — all within a single library. No external server. No network. Just a file.
| Feature |
Description |
| 🗄️ Zero-config |
Open a file, start querying — no setup, no config files |
| 📄 JSON Native |
Store, query, and index JSON documents directly |
| 🔍 SQL Queries |
SELECT, INSERT, UPDATE, DELETE with WHERE, ORDER BY, LIMIT |
| 📊 Aggregations |
COUNT, SUM, AVG, MIN, MAX, GROUP BY |
| 🔎 Full-text Search |
Built-in text search across documents |
| 🌳 B-Tree Indexes |
Secondary indexes for fast lookups |
| 🔒 ACID Transactions |
Reliable, consistent data operations |
| 🗜️ Compression |
zstd compression for efficient storage |
| 🔐 Encryption |
AES-256-GCM at-rest encryption |
| 🛡️ Security Hardened |
Key from env vars, query_safe() injection blocking, auto chmod 600, WAL cleanup, thread-safe wrappers |
| 🌍 Cross-platform |
Windows, Linux, macOS |
| 🔗 Multi-language |
Rust, Python, Node.js, Java, Go, C/C++ |
Quick Start
Install
Option 1 — Download prebuilt binary:
Option 2 — Add as Rust dependency:
[dependencies]
overdrive-db = "1.3.0"
Use
use overdrive::OverDriveDB;
use serde_json::json;
fn main() {
let mut db = OverDriveDB::open("myapp.odb").unwrap();
db.create_table("users").unwrap();
let id = db.insert("users", &json!({
"name": "Alice",
"email": "alice@example.com",
"age": 30,
"tags": ["admin", "developer"]
})).unwrap();
println!("Inserted user with ID: {}", id);
let result = db.query("SELECT * FROM users WHERE age > 25 ORDER BY name").unwrap();
println!("Found {} users in {:.2}ms", result.rows.len(), result.execution_time_ms);
for row in &result.rows {
println!(" → {} ({})", row["name"], row["email"]);
}
let matches = db.search("users", "alice").unwrap();
println!("Search found {} matches", matches.len());
let user = db.get("users", &id).unwrap();
println!("Got: {:?}", user);
db.update("users", &id, &json!({"age": 31})).unwrap();
let count = db.count("users").unwrap();
println!("Total users: {}", count);
db.close().unwrap();
}
That's it. No server to install. No docker. No config. Just add the dependency and go.
API Reference
📖 Full API docs: docs/api-reference.md
Database Lifecycle
| Method |
Description |
OverDriveDB::open(path) |
Open or create a database |
OverDriveDB::create(path) |
Create new (error if exists) |
OverDriveDB::open_existing(path) |
Open existing (error if not found) |
db.close() |
Close and release resources |
db.sync() |
Force flush to disk |
OverDriveDB::destroy(path) |
Delete database file |
OverDriveDB::version() |
Get SDK version |
Table Management
| Method |
Description |
db.create_table(name) |
Create a new table |
db.drop_table(name) |
Drop a table and all data |
db.list_tables() |
List all table names |
db.table_exists(name) |
Check if a table exists |
CRUD Operations
| Method |
Description |
db.insert(table, &json) |
Insert document, returns _id |
db.insert_batch(table, &[json]) |
Batch insert, returns Vec<_id> |
db.get(table, id) |
Get document by _id |
db.update(table, id, &json) |
Update document fields |
db.delete(table, id) |
Delete document |
db.count(table) |
Count documents |
db.scan(table) |
Get all documents |
SQL Queries
| Method |
Description |
db.query(sql) |
Execute SQL, returns QueryResult |
db.query_safe(sql, &[params]) |
✅ Parameterized query — safe for user input |
SELECT * FROM users WHERE age > 25 ORDER BY name DESC LIMIT 10 OFFSET 5
SELECT COUNT(*), AVG(age) FROM users
INSERT INTO users VALUES {"name": "Bob", "age": 25}
UPDATE users SET {"age": 26} WHERE name = 'Bob'
DELETE FROM users WHERE age < 18
CREATE TABLE products
DROP TABLE products
SHOW TABLES
Search & Indexing
| Method |
Description |
db.search(table, text) |
Full-text search |
db.create_index(table, column) |
Create B-Tree index |
db.drop_index(name) |
Drop an index |
Security APIs (v1.3.0)
| Method |
Threat Mitigated |
Description |
OverDriveDB::open_encrypted(path, "ODB_KEY") |
🔴 Key hardcoding |
Reads AES key from env var, zeroed on drop |
db.query_safe(sql, &[params]) |
🟠 SQL injection |
Parameterized query with injection detection |
db.backup(dest_path) |
🔴 Ransomware/deletion |
Encrypted backup copy + permission hardening |
db.cleanup_wal() |
🟡 WAL replay |
Deletes stale WAL after commit |
SharedDB::open(path) |
🟠 Race condition |
Thread-safe Arc+Mutex wrapper |
Auto on open() |
🟡 Unauthorized access |
chmod 600 / Windows ACL on every open |
use overdrive::OverDriveDB;
use overdrive::shared::SharedDB;
let mut db = OverDriveDB::open_encrypted("app.odb", "ODB_KEY")?;
let rows = db.query_safe(
"SELECT * FROM users WHERE name = ?",
&[user_input], )?;
db.backup("offsite/app_backup.odb")?;
let txn = db.begin_transaction(IsolationLevel::ReadCommitted)?;
db.commit_transaction(&txn)?;
db.cleanup_wal()?;
let shared = SharedDB::open("app.odb")?;
let db2 = shared.clone();
std::thread::spawn(move || db2.query("SELECT * FROM users"));
Statistics
| Method |
Description |
db.stats() |
Get Stats { tables, total_records, file_size_bytes, path } |
Python SDK
pip install overdrive-db
from overdrive import OverDrive, ThreadSafeOverDrive
import os
with OverDrive("myapp.odb") as db: db.create_table("users")
user_id = db.insert("users", {"name": "Alice", "email": "alice@example.com", "age": 30})
results = db.query_safe("SELECT * FROM users WHERE age > ?", [25])
for row in results:
print(f" {row['name']} — {row['email']}")
matches = db.search("users", "alice")
db.backup("backups/app.odb")
db.cleanup_wal()
os.environ["ODB_KEY"] = "my-secret-key"
db = ThreadSafeOverDrive.open_encrypted("app.odb", "ODB_KEY")
Node.js SDK
npm install overdrive-db
const { OverDrive, SharedOverDrive } = require('overdrive-db');
const db = new OverDrive('myapp.odb');
db.createTable('products');
const id = db.insert('products', { name: 'Laptop', price: 999.99 });
const results = db.querySafe('SELECT * FROM products WHERE price > ?', ['500']);
console.table(results);
db.backup('backups/products.odb');
db.cleanupWal();
const shared = new SharedOverDrive('app.odb');
await shared.query('SELECT * FROM products');
db.close();
C / C++ API
#include "overdrive.h"
int main() {
ODB* db = overdrive_open("myapp.odb");
if (!db) {
printf("Error: %s\n", overdrive_last_error());
return 1;
}
overdrive_create_table(db, "users");
char* id = overdrive_insert(db, "users",
"{\"name\":\"Alice\",\"age\":30}");
printf("Inserted: %s\n", id);
overdrive_free_string(id);
char* result = overdrive_query(db,
"SELECT * FROM users WHERE age > 25");
printf("Results: %s\n", result);
overdrive_free_string(result);
char* matches = overdrive_search(db, "users", "alice");
printf("Search: %s\n", matches);
overdrive_free_string(matches);
overdrive_close(db);
return 0;
}
Memory rule: Every char* returned by overdrive_* functions must be freed with overdrive_free_string(). The ODB* handle must be closed with overdrive_close().
Go SDK
go get github.com/ALL-FOR-ONE-TECH/OverDrive-DB_SDK/go
import "github.com/ALL-FOR-ONE-TECH/OverDrive-DB_SDK/go"
func main() {
db, _ := overdrive.Open("myapp.odb")
defer db.Close()
db.CreateTable("users")
id, _ := db.Insert("users", map[string]any{"name": "Alice", "age": 30})
results, _ := db.QuerySafe("SELECT * FROM users WHERE age > ?", "25")
safe, _ := overdrive.OpenSafe("app.odb")
go safe.Query("SELECT * FROM users")
db.Backup("backups/app.odb")
db.CleanupWAL()
_ = id
}
Java SDK
<dependency>
<groupId>com.afot</groupId>
<artifactId>overdrive-db</artifactId>
<version>1.3.0</version>
</dependency>
import com.afot.overdrive.OverDrive;
import com.afot.overdrive.OverDriveSafe;
import java.util.Map;
public class Main {
public static void main(String[] args) throws Exception {
try (OverDrive db = OverDrive.open("myapp.odb")) {
db.createTable("users");
String id = db.insert("users", Map.of("name", "Alice", "age", 30));
var rows = db.querySafe("SELECT * FROM users WHERE name = ?", userInput);
db.backup("backups/app.odb");
db.cleanupWal();
}
try (OverDriveSafe safe = OverDriveSafe.open("app.odb")) {
safe.insert("users", Map.of("name", "Bob"));
}
}
}
Architecture
┌─────────────────────────────────────┐
│ Your Application │
│ │
│ db = OverDriveDB::open("app.odb") │
│ db.query_safe("WHERE name = ?", …) │
│ shared = SharedDB::open(…) │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ OverDrive SDK (1.3.0) — Secure │
│ │
│ OverDriveDB │ QueryEngine │ FFI │
│ SharedDB │ query_safe │ │
│ SecretKey │ set_perms │ │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ OverDrive Engine (0.2.0) │
│ │
│ B-Tree │ WAL │ MVCC │ Index │
│ Pages │ zstd │ AES │ Cache │
└─────────────────────────────────────┘
│
┌─────▼─────┐
│ app.odb │ ← AES-256-GCM encrypted
│ (chmod 600│ owner-only permissions
└────────────┘
- No network — everything runs in-process
- No server — just a library and a file
- No config — open and go
Comparison
| Feature |
OverDrive |
SQLite |
MongoDB |
Redis |
| Deployment |
Library |
Library |
Server |
Server |
| Data Model |
JSON Documents |
Relational |
JSON Documents |
Key-Value |
| SQL Support |
✅ |
✅ |
❌ |
❌ |
| Schema |
Optional |
Required |
Optional |
None |
| Full-text Search |
✅ Built-in |
FTS5 Extension |
✅ |
❌ |
| Encryption |
✅ AES-256 |
SEE (paid) |
✅ Enterprise |
✅ |
| Compression |
✅ zstd |
❌ |
✅ |
❌ |
| Versioning |
✅ Git-like |
❌ |
❌ |
❌ |
| Size |
~1.4MB |
~1.2MB |
~200MB |
~3MB |
Building from Source
git clone https://github.com/ALL-FOR-ONE-TECH/OverDrive-DB_SDK.git
cd OverDrive-DB_SDK
cargo build
cargo build --release
cargo test --lib
cargo test
Build Outputs
| Platform |
File |
Location |
| Windows |
overdrive.dll |
target/release/ |
| Linux |
liboverdrive.so |
target/release/ |
| macOS |
liboverdrive.dylib |
target/release/ |
Project Structure
OverDrive-DB_SDK/
├── Cargo.toml # Crate configuration (v1.3.0)
├── README.md # This file
├── LICENSE # MIT License
│
├── src/
│ ├── lib.rs # OverDriveDB + all security APIs
│ ├── shared.rs # SharedDB — thread-safe wrapper (NEW v1.3.0)
│ ├── query_engine.rs # Embedded SQL parser & executor
│ ├── result.rs # SdkError types (SecurityError, BackupError)
│ └── ffi.rs # C FFI extern functions
│
├── python/overdrive/
│ └── __init__.py # Python ctypes wrapper + security APIs
│
├── nodejs/
│ └── index.js # Node.js ffi-napi wrapper + security APIs
│
├── go/
│ └── overdrive.go # Go CGo bindings + security APIs + SafeDB
│
├── java/src/.../
│ ├── OverDrive.java # Java JNA wrapper + security APIs
│ └── OverDriveSafe.java # Thread-safe wrapper (in OverDrive.java)
│
├── docs/
│ ├── quickstart.md # Getting started guide
│ ├── api-reference.md # Full API documentation
│ ├── sql-guide.md # SQL syntax reference
│ ├── python-guide.md # Python SDK guide
│ ├── nodejs-guide.md # Node.js SDK guide
│ ├── c-guide.md # C/C++ integration guide
│ └── architecture.md # Architecture + v1.3.0 Security Model
│
└── examples/
├── basic_crud.rs # Basic CRUD operations
├── sql_queries.rs # SQL query examples
├── batch_ops.rs # Batch operations
└── secure_open.rs # 🔐 Security hardening demo (NEW v1.3.0)
Links
License
Licensed under either of:
at your option.
#afot #OverDriveDb #InCodeSDK #EmbeddedDB #MrV2K #AllForOneTech #EmbeddeDB #HybridDB