Skip to main content

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 dashboard loading from any folder
  • API endpoints unified under /api/ prefix
  • start.py always 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

neevdb-3.0.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neevdb-3.0.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file neevdb-3.0.1.tar.gz.

File metadata

  • Download URL: neevdb-3.0.1.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

Hashes for neevdb-3.0.1.tar.gz
Algorithm Hash digest
SHA256 81a2f51c2bafad2655179f53109870ead9df0e6431a423e9035dd6ce6f1165eb
MD5 1781fc5f07be6db0bb1f265546191273
BLAKE2b-256 f0043ccaa6dbff767202ab2519c0aa97e3bb847ee835c5d8cda8c8925f99ced0

See more details on using hashes here.

File details

Details for the file neevdb-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: neevdb-3.0.1-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

Hashes for neevdb-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37fe24c910fb78292f2073fc974d4855354d06615f427f8eb458125c18e260e1
MD5 b4bdfdbb7930dc77957ca949c3379ebb
BLAKE2b-256 bf48539a9df38b03180cbf26169f10a71f9a856300909866c3af0ac0e8d53000

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page