MiniDB is a lightweight command-line database engine written in Python that stores tables as JSON files. It allows you to create tables, insert records, query data, update rows, and delete entries directly from the terminal.
This project is designed to understand how database systems work internally, including concepts like table schemas, CRUD operations, and command interpreters.
- Create and delete tables
- Store data in JSON files
- Insert records with automatic ID generation
- Select and filter records
- Update existing rows
- Delete rows by condition
- Command-line interface
- Simple logging system
- Automatic column creation during inserts
Clone the repository:
git clone https://github.com/Dhruv-Cmds/MiniDataBase.git
cd MiniDataBasecd Make sure you have Python installed:
python --versionRun the database engine:
python main.pyOnce started, the database will show the command prompt:
DB>
Type commands to interact with the database.
Creates a new table.
create_table
Example:
Enter Table name: students
Enter columns (comma separated): name,age
Displays the contents of a table.
show_tables
Deletes a table file.
delete_table
Insert data using key=value pairs.
insert students name=alex age=21
Show all rows:
select students
Filter rows:
select students where age=21
Update a row using a condition.
update students id=1 age=22
Delete a row using a condition.
delete students id=1
MiniDB v1.0
System ready.
DB> create_table
Enter Table name: students
Enter columns (comma separated): name,age
DB> insert students name=alex age=21 city=Houston country=America
DB> insert students name=emma age=22 city=London country=UK
DB> select students
{'id': '1', 'name': 'alex', 'age': '21', 'city': Houston, 'country': America}
{'id': '2', 'name': 'emma', 'age': '22', 'city': London, 'country': UK}
DB> update students id=1 age=23
DB> delete students id=2
MiniDataBase/
β
βββ database/ # JSON table storage
β βββ logs.txt
β βββ students.json
β
βββ Databasemain
β βββ database.py # database engine and CRUD operations
β βββ logger.py # logging utility
β βββ main.py # command interpreter and boot system
β
βββ README.md
MiniDB stores each table as a JSON file inside the database/ directory.
Example table structure:
{
"columns": ["id", "name", "age"],
"rows": [
{"id": "1", "name": "alex", "age": "21"}
]
}The engine loads the JSON file, modifies the data in memory, and writes the changes back to disk.
This project demonstrates core database concepts:
- Table schemas
- Data persistence
- Command parsing
- CRUD operations
- Simple query filtering
It is a small but practical step toward understanding how real databases like SQLite or PostgreSQL work internally.
This project is open source and available under the MIT License.








