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 โ€” 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 .json file
  • 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 True input 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

neevdb-2.0.0.tar.gz (11.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-2.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

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

Hashes for neevdb-2.0.0.tar.gz
Algorithm Hash digest
SHA256 942457c0a38f6b2b63a7a5bb31cfbd05980e8357dd8b2806481835d2f0ebd07e
MD5 1f0231b3f99a2bcdd2ccba44a79397a6
BLAKE2b-256 4389d5f66ea0fddcba1625a1828abc2b94babc8de3dc5866b4e25fd6126b0569

See more details on using hashes here.

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

Hashes for neevdb-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 996edc463503df5ee6a79625db29e3677d1a21b029a0e197bc2ebb38358622ce
MD5 86ede54375c1fa5b859e300c359a3186
BLAKE2b-256 593cae6f0ea2d62de4ee1555f786a1a4bdbb148d391408bf31e1755aa90e5503

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