A lightweight file-based database engine built with pure Python
Project description
NeevDB ๐๏ธ
A lightweight, file-based database engine built with pure Python โ zero dependencies, zero setup.
NeevDB ("neev" = foundation in Hindi) is a database engine written from scratch in Python. It supports tables, CRUD operations, SQL-like queries, an interactive CLI shell, and a full REST API server.
๐ฆ Install
# Core โ zero dependencies
pip install neevdb
# With REST API server support
pip install neevdb[server]
๐ Project 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
โ โโโ server.py # Optional REST API server (FastAPI)
โโโ tests/
โ โโโ test_core.py # Core test suite (12 tests)
โ โโโ test_v2.py # Full test suite (50+ tests)
โโโ api.py # FastAPI REST API server
โโโ cli.py # Interactive terminal shell
โโโ dashboard.html # Browser dashboard UI
โโโ start.py # One-command server launcher
โโโ pyproject.toml # Package config
โโโ README.md
โก Quick Start
from neevdb import NeevDB
db = NeevDB("mydata.json")
db.create_table("users")
db.insert("users", {"name": "Alice", "age": 25, "city": "Mumbai"})
db.insert("users", {"name": "Bob", "age": 17, "city": "Delhi"})
# Find all
all_users = db.find_all("users")
# Find with condition
adults = db.find("users", lambda row: row["age"] > 18)
# Update
db.update("users", lambda row: row["name"] == "Bob", {"age": 20})
# Delete
db.delete("users", lambda row: row["name"] == "Alice")
# Count
total = db.count("users")
๐ Query Engine
db.query("SELECT * FROM users")
db.query("SELECT * FROM users WHERE age > 18")
db.query("SELECT name, city FROM users")
db.query("SELECT * FROM users ORDER BY age")
db.query("SELECT * FROM users ORDER BY age DESC")
db.query("SELECT * FROM users LIMIT 5")
db.query("SELECT name, city FROM users WHERE age > 18 ORDER BY name LIMIT 3")
Supported WHERE operators
| Operator | Meaning | Example |
|---|---|---|
= |
Equal to | WHERE city = Mumbai |
!= |
Not equal to | WHERE status != draft |
> |
Greater than | WHERE age > 18 |
< |
Less than | WHERE price < 500 |
>= |
Greater or equal | WHERE score >= 90 |
<= |
Less or equal | WHERE stock <= 10 |
๐ REST API Server
Start the server with one command:
python start.py
Or with a custom database file:
python start.py mydata.json
Browser opens automatically at http://localhost:8000 with the dashboard.
From Python:
from neevdb.server import start
start(db_path="mydata.json", host="0.0.0.0", port=8000)
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api |
Health check |
| GET | /api/stats |
Database statistics |
| GET | /api/tables |
List all tables |
| POST | /api/tables/{name} |
Create a table |
| DELETE | /api/tables/{name} |
Drop a table |
| GET | /api/tables/{name}/records |
Get records (+ filters) |
| GET | /api/tables/{name}/records/{id} |
Get record by ID |
| POST | /api/tables/{name}/records |
Insert a record |
| PUT | /api/tables/{name}/records/{id} |
Update a record |
| DELETE | /api/tables/{name}/records/{id} |
Delete a record |
| POST | /api/query |
Run SQL-like query |
Query parameters for GET /records
?where=age>18 โ Filter records
?order=name โ Sort by field
?desc=true โ Sort descending
?limit=5 โ Max records
Use from any frontend
// Fetch users older than 18, sorted by name
const res = await fetch('http://localhost:8000/api/tables/users/records?where=age>18&order=name')
const data = await res.json()
console.log(data.records)
// Insert a record
await fetch('http://localhost:8000/api/tables/users/records', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ data: { name: 'Alice', age: 25 } })
})
// Run a query
const res = await fetch('http://localhost:8000/api/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: 'SELECT * FROM users WHERE age > 18 ORDER BY name LIMIT 5' })
})
๐ป CLI Shell
python cli.py
python cli.py mydata.json
NeevDB > SHOW TABLES
NeevDB > CREATE TABLE users
NeevDB > INSERT INTO users name=Alice age=25 city=Mumbai
NeevDB > SELECT * FROM users WHERE age > 18
NeevDB > SELECT * FROM users ORDER BY age DESC LIMIT 5
NeevDB > DELETE FROM users WHERE name = Alice
NeevDB > DROP TABLE users
NeevDB > HELP
NeevDB > EXIT
๐งช Running Tests
# Core tests (12 tests)
python tests/test_core.py
# Full test suite (50+ tests)
python tests/test_v2.py
๐ ๏ธ How It Works
Your Code / CLI / Browser
โ
โผ
NeevDB Core โ CRUD operations, table management
โ
โโโโบ Query Engine โ Parses SQL-like strings
โ
โโโโบ Storage โ Reads/writes JSON file to disk
โ
โโโโบ REST API โ FastAPI server (optional)
โ
โโโโบ Dashboard HTML โ Browser UI
๐ฆ Zero Dependencies (Core)
| Module | Used for |
|---|---|
json |
Saving and loading data |
os |
File path checks |
re |
Query string parsing |
datetime |
Auto-generating timestamps |
sys |
CLI argument handling |
Optional server dependencies: fastapi, uvicorn
๐ Built By
Manish Dange โ built NeevDB from scratch as a learning project. "Neev" means foundation in Hindi โ this is the foundation of something bigger.
๐ Changelog
v3.0.1
- Fixed bug and errors
v3.0.1
- Fixed dashboard loading from any folder
- API endpoints unified under
/api/prefix start.pyalways runs from correct directory
v3.0.0
- Fixed dashboard loading from any folder
- Improved error messages
v2.0.0
- Optional REST API server (
pip install neevdb[server]) from neevdb.server import startโ one line server start- Dashboard HTML UI
- Full test suite (50+ tests)
v1.0.0
- JSON file storage
- Tables, CRUD operations
- SQL-like query engine (SELECT/WHERE/ORDER BY/LIMIT)
- Interactive CLI shell
- 12 passing tests
๐ Roadmap
- Phase 1 โ JSON storage, Tables, CRUD
- Phase 2 โ Query Engine (SELECT/WHERE/ORDER BY/LIMIT)
- Phase 3 โ Interactive CLI Shell
- Phase 4 โ PyPI publish (
pip install neevdb) - Phase 5 โ REST API server + Browser Dashboard
- Phase 6 โ Indexes for faster queries
- Phase 7 โ Multi-table JOIN support
- Phase 8 โ Deploy to cloud (Railway/Render)
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-3.0.2.tar.gz.
File metadata
- Download URL: neevdb-3.0.2.tar.gz
- Upload date:
- Size: 12.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 |
6d37c8b9e8902fe7b84bc6db6fc95116ba1b888caf5c450b22d92e1f905df40e
|
|
| MD5 |
c7d1c83ed2ec6bd0051f49485ac9f22a
|
|
| BLAKE2b-256 |
0503c5cadb1bdb94dfc67c6455b4f8086c830a4f183ee205dea62493a70fc2c7
|
File details
Details for the file neevdb-3.0.2-py3-none-any.whl.
File metadata
- Download URL: neevdb-3.0.2-py3-none-any.whl
- Upload date:
- Size: 11.4 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 |
0e40e058d4927232200e728e4b64004b37d41fe92f8e9ece1bf0033f96338e0f
|
|
| MD5 |
ec38ac5463caaab4d1701c53ee98aff7
|
|
| BLAKE2b-256 |
7ab41c2444195e0c506e2a352b510be1483ee87c7be50a9913910b643428f484
|