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-1.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

neevdb-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neevdb-1.0.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for neevdb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3c3f8fcc61129e3d50755ba7e579246a07c1628fcfb493c6903fd9a78276fbc9
MD5 36b0b1179b2c996e6f97d212b2dfb2d3
BLAKE2b-256 71bb0a61c0f8699bfaf2b6be138bbe2c5d4725328a3ebbb3607435d6571a8552

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neevdb-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9440762df972f174bc96afe23dcb30e353ffe5b07901e1a85686bc7907f1509
MD5 c46fa31d11936d27d03d79ef15436157
BLAKE2b-256 3dafaf5dec6935835069fea148c88f79db14a1ea86f004c711dceca26f3609eb

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