| Crates.io | rustql_lavanya |
| lib.rs | rustql_lavanya |
| version | 0.1.0 |
| created_at | 2025-11-09 15:36:33.049881+00 |
| updated_at | 2025-11-09 15:36:33.049881+00 |
| description | A lightweight, persistent SQL engine in Rust |
| homepage | |
| repository | https://github.com/lavavarshney/rustql |
| max_upload_size | |
| id | 1924229 |
| size | 51,909 |
A high-performance, in-memory SQL-like query engine implemented in Rust, featuring full CRUD semantics, symbolic column resolution, and zero-downtime persistence via binary serialization.
Designed for systems programming education, embedded data processing, and prototyping lightweight persistence layers.
| Feature | Implementation |
|---|---|
CREATE TABLE |
Schema definition with named columns |
INSERT INTO |
Row ingestion (i32, &str) |
SELECT |
Projection over * or named/positional columns |
UPDATE |
In-place mutation with conditional filtering |
DELETE |
Row eviction via equality predicates |
| Column Resolution | Dual-mode: symbolic (name) + positional (colN) |
| Persistence | bincode-serialized database.bin |
| Auto-Save | Post-execution flush on success |
| REPL CLI | Interactive command loop with debug introspection |
src/
├── main.rs → REPL + lifecycle (load/save)
├── parser.rs → Lexical analysis + recursive descent parsing
└── executor.rs → Query execution, table ops, persistence
HashMap<String, Table> with Vec<Vec<Value>> storageserde + bincode for compact, type-safe persistenceValue::Int(i32) | Value::Str(String) | Value::Star | Value::Identifierrustc >= 1.70
cargo
git clone https://github.com/lavavarshney/rustql.git
cd rustql
cargo run --release
First run:
Starting with new database
Subsequent:Loaded existing database from database.bin
Mini SQL Engine - Enter SQL commands (type 'quit' to exit)
Supported: CREATE | INSERT | SELECT | UPDATE | DELETE
> CREATE TABLE metrics (ts, cpu, mem);
OK
> INSERT INTO metrics VALUES (1700000000, 78, 4096);
OK
> SELECT cpu, mem FROM metrics WHERE ts = 1700000000;
["78", "4096"]
OK
> UPDATE metrics SET cpu = 45 WHERE mem > 4000;
Updated 1 rows
OK
> quit
Database saved to database.bin
CREATE TABLECREATE TABLE t (c1, c2, c3);
→ Allocates schema vector; column names stored for symbolic lookup.
INSERT INTOINSERT INTO t VALUES (1, 'data', 3.14);
→ Appends row; type inference at parse time.
SELECTSELECT * FROM t;
SELECT col0, name FROM t;
SELECT cpu FROM metrics;
→ Supports * expansion and dual-resolution column projection.
UPDATEUPDATE t SET col1 = 'new' WHERE id = 1;
UPDATE t SET cpu = 99 WHERE ts = 1700000000;
→ Parses SET and WHERE clauses; applies mutation in-place.
DELETEDELETE FROM t WHERE status = 'inactive';
DELETE FROM t WHERE col0 = 42;
→ Equality-based retention filter with debug tracing.
database.bin (project root)bincode v1.3 (LEB128 + varint)Database::load)savestd::fs::writeresolve_column(name: &str, schema: &[String]) -> usize
schema.iter().position(|c| c == name)name.starts_with("col") → parse index0 (fail-soft)Enables backward compatibility with positional syntax.
| Command | Function |
|---|---|
save |
Force persistence flush |
quit |
Graceful shutdown + save |
debug |
Dump internal state (schema, rows, types) |
CREATE TABLE sensors (id, type, value);
INSERT INTO sensors VALUES (1, 'temp', 23);
INSERT INTO sensors VALUES (2, 'hum', 65);
SELECT type, value FROM sensors;
UPDATE sensors SET value = 24 WHERE id = 1;
DELETE FROM sensors WHERE value < 50;
SELECT * FROM sensors;
save
quit
| Feature | Status | Notes |
|---|---|---|
WHERE logic |
= only |
No AND/OR/>/</!= |
| Schema enforcement | None | No type checking |
| Indexing | Not supported | O(n) scans |
| Transactions | Not supported | No rollback |
| Concurrency | Single-threaded | REPL-only |
Future Extensions:
JOIN supportDEMO_SESSION.md – End-to-end sessionsQUICK_REFERENCE.md – Syntax cheat sheetTEST_EXAMPLES.md – Regression scenarios[dependencies]
serde = { version = "1.0", features = ["derive"] }
bincode = "1.3"
stdWe welcome systems-level contributions:
LIKE, IN, comparison opsproptest)MIT License