A lightweight file-based database engine built with pure Python
Project description
NeevDB ๐๏ธ
A lightweight, file-based database engine built with pure Python โ no dependencies, no setup, just run.
NeevDB ("neev" = foundation in Hindi) is a simple database engine written from scratch in Python.
It supports tables, CRUD operations, SQL-like queries, and an interactive CLI shell.
๐ Folder Structure
NeevDB/
โโโ neevdb/
โ โโโ __init__.py # Package entry point
โ โโโ core.py # Main database engine (CRUD + Query)
โ โโโ storage.py # File read/write layer
โ โโโ query.py # SQL-like query parser and executor
โโโ tests/
โ โโโ test_core.py # Full test suite (12 tests)
โโโ cli.py # Interactive terminal shell
โโโ README.md # You are here
โก Quick Start
from neevdb import NeevDB
# Connect to (or create) a database file
db = NeevDB("mydata.json")
# Create a table
db.create_table("users")
# Insert records
db.insert("users", {"name": "Alice", "age": 25, "city": "Mumbai"})
db.insert("users", {"name": "Bob", "age": 17, "city": "Delhi"})
# Find all records
all_users = db.find_all("users")
# Find with a condition
adults = db.find("users", lambda row: row["age"] > 18)
# Update records
db.update("users", lambda row: row["name"] == "Bob", {"age": 20})
# Delete records
db.delete("users", lambda row: row["name"] == "Alice")
# Count records
total = db.count("users")
๐ Query Engine
NeevDB supports SQL-like query strings:
# Select all records
db.query("SELECT * FROM users")
# Filter with WHERE
db.query("SELECT * FROM users WHERE age > 18")
# Select specific columns
db.query("SELECT name, city FROM users")
# Sort with ORDER BY
db.query("SELECT * FROM users ORDER BY age")
db.query("SELECT * FROM users ORDER BY age DESC")
# Limit results
db.query("SELECT * FROM users LIMIT 5")
# Combine everything
db.query("SELECT name, city FROM users WHERE age > 18 ORDER BY name LIMIT 3")
Supported WHERE operators:
| Operator | Meaning |
|---|---|
= |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater or equal |
<= |
Less or equal |
๐ป CLI Shell
Launch the interactive terminal shell:
python cli.py
Or connect to a specific database file:
python cli.py mydata.json
CLI Commands:
NeevDB > SHOW TABLES
NeevDB > CREATE TABLE users
NeevDB > INSERT INTO users name=Alice age=25 city=Mumbai
NeevDB > SELECT * FROM users
NeevDB > SELECT * FROM users WHERE age > 18
NeevDB > SELECT * FROM users ORDER BY age DESC LIMIT 3
NeevDB > DELETE FROM users WHERE name = Alice
NeevDB > DROP TABLE users
NeevDB > HELP
NeevDB > EXIT
Example CLI session:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
NeevDB v1.0 โ Interactive Shell
Database: neevdb.json
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Type HELP for commands, EXIT to quit.
NeevDB > CREATE TABLE users
Table 'users' created.
NeevDB > INSERT INTO users name=Manish age=21 city=Indore
Inserted record with _id=1 into 'users'.
NeevDB > SELECT * FROM users
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
name age city
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Manish 21 Indore
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1 row(s)
NeevDB > EXIT
Goodbye! NeevDB closed.
๐งช Running Tests
python tests/test_core.py
Expected output:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
NeevDB - Full Test Suite
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
All 12 tests PASSED! NeevDB Phase 2 complete! ๐
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ๏ธ How It Works
Your Code / CLI
โ
โผ
NeevDB Core โ CRUD operations, table management
โ
โโโโบ Query Engine โ Parses SQL-like strings, filters, sorts, limits
โ
โโโโบ Storage โ Reads and writes JSON file to disk
- Storage layer โ All data is saved in a human-readable
.jsonfile - Core engine โ Manages tables and records in memory, syncs to disk on every change
- Query engine โ Parses query strings using
re(regex), executes filters/sort/limit - CLI shell โ A
while Trueinput loop that parses commands and calls the engine
๐ฆ No Dependencies
NeevDB uses only Python built-in modules:
| Module | Used for |
|---|---|
json |
Saving and loading data |
os |
File path and existence checks |
re |
Query string parsing |
datetime |
Auto-generating timestamps |
sys |
CLI argument handling |
No pip install required. Works on Python 3.7+.
๐ Built By
Manish โ built NeevDB from scratch as a learning project.
"Neev" means foundation in Hindi โ this is the foundation of something bigger.
๐ Roadmap
- Phase 1 โ JSON storage, Tables, CRUD
- Phase 2 โ Query Engine (SELECT / WHERE / ORDER BY / LIMIT)
- Phase 3 โ Interactive CLI Shell
- Phase 4 โ
pip install neevdb(publish to PyPI) - Phase 5 โ Indexes for faster queries
- Phase 6 โ Multi-table JOIN support
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neevdb-2.0.0.tar.gz.
File metadata
- Download URL: neevdb-2.0.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
942457c0a38f6b2b63a7a5bb31cfbd05980e8357dd8b2806481835d2f0ebd07e
|
|
| MD5 |
1f0231b3f99a2bcdd2ccba44a79397a6
|
|
| BLAKE2b-256 |
4389d5f66ea0fddcba1625a1828abc2b94babc8de3dc5866b4e25fd6126b0569
|
File details
Details for the file neevdb-2.0.0-py3-none-any.whl.
File metadata
- Download URL: neevdb-2.0.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
996edc463503df5ee6a79625db29e3677d1a21b029a0e197bc2ebb38358622ce
|
|
| MD5 |
86ede54375c1fa5b859e300c359a3186
|
|
| BLAKE2b-256 |
593cae6f0ea2d62de4ee1555f786a1a4bdbb148d391408bf31e1755aa90e5503
|