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 to return

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, city: 'Mumbai' } })
})

// Run a SQL-like 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' })
})
const data = await res.json()
console.log(data.records)

๐Ÿ’ป 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

Expected output:

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
  All tests PASSED! NeevDB is solid! ๐Ÿš€
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ› ๏ธ 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
  • Storage layer โ€” All data saved in a human-readable .json file
  • Core engine โ€” Manages tables and records, syncs to disk on every change
  • Query engine โ€” Parses query strings using regex, executes filters/sort/limit
  • CLI shell โ€” Interactive terminal with a while True input loop
  • REST API โ€” Full FastAPI server with CORS support, auto docs at /docs
  • Dashboard โ€” Browser UI to view, insert, edit, delete records visually

๐Ÿ“ฆ 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: pip install neevdb[server] installs 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.3 โ€” Latest โœ…

  • Fixed pip install neevdb[server] โ€” no more warnings
  • Removed conflicting setup.py โ€” now uses only pyproject.toml
  • [server] optional dependency now correctly installs fastapi + uvicorn
  • Dashboard auto-discovery from any folder

v3.0.2

  • Version bump with pyproject.toml improvements

v3.0.1

  • Fixed dashboard loading from any folder
  • API endpoints unified under /api/ prefix
  • start.py always runs from correct directory
  • Improved error messages

v3.0.0

  • Major release with REST API server
  • Browser dashboard UI (dashboard.html)
  • from neevdb.server import start โ€” one line server launch
  • python start.py โ€” one command to open dashboard in browser

v2.0.0

  • Optional REST API server (pip install neevdb[server])
  • Full test suite (50+ tests)
  • server.py module added to neevdb package

v1.0.0

  • JSON file storage
  • Tables, CRUD operations
  • SQL-like query engine (SELECT / WHERE / ORDER BY / LIMIT)
  • Interactive CLI shell (cli.py)
  • 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 โ€” Clean packaging (pip install neevdb[server])
  • Phase 7 โ€” Indexes for faster queries
  • Phase 8 โ€” Multi-table JOIN support
  • Phase 9 โ€” 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.3.tar.gz (14.3 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.3-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neevdb-3.0.3.tar.gz
  • Upload date:
  • Size: 14.3 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.3.tar.gz
Algorithm Hash digest
SHA256 a71d14ff0557b012a352f3c2d0dc0518f8a808b4d83d15777f0dc39e147b42f0
MD5 97db0dc44cf91c4ab443ffb56b696ea4
BLAKE2b-256 82348cb199ecb1e009b731083fe006861b7d534f897c3ab9545f98ce047fb772

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neevdb-3.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b77452f32ebd6acbf3a80ce4e821a7924b7a10aae8fab09661a4fe6a8409605
MD5 3e2f99f9bdb804292e377d9f0ce074f8
BLAKE2b-256 f0c3d7aa1ad5c7315e5f64226393ccc183a72598c03ac5b5e80bae1a31ebb3d2

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