The JsonDB Project provides a lightweight, file-based database system, designed to make data storage and retrieval simple and intuitive. Built in Python, it leverages the versatility of JSON for data manipulation, making it an ideal solution for small projects, prototypes, or for educational purposes where a full-scale database system isn't required.
- Simple CRUD Operations: Easily create, read, update, and delete records with straightforward Python methods.
- Lightweight and Portable: No need for complex database setups. Your data is stored in a single JSON file.
- Flexible Data Models: Store anything from simple key-value pairs to complex nested structures.
- Search Functionality: Includes basic search capabilities to filter through data based on keys or patterns.
- Minimal Setup: With just a few lines of code, integrate JsonDB into any Python project.
- Python 3.6 or newer
You can download the jsonDB.py
file directly for your platform using the following commands:
Option 1: Using PowerShell (no extra installations needed): Open PowerShell and run:
Invoke-WebRequest -Uri https://raw.githubusercontent.com/DavyJonesCodes/json-db-python/master/jsonDB.py -OutFile jsonDB.py
Option 2: Using wget
:
If you have wget
installed, you can use the following command in Command Prompt or PowerShell:
wget -O jsonDB.py https://raw.githubusercontent.com/DavyJonesCodes/json-db-python/master/jsonDB.py
Open your terminal and run:
wget -O jsonDB.py https://raw.githubusercontent.com/DavyJonesCodes/json-db-python/master/jsonDB.py
Here's how to get started with JsonDB in your project:
from jsonDB import JsonDB
# Initialize the database
db = JsonDB('data.json')
# Adding data
db['user1'] = {'name': 'John Doe', 'age': 30}
db['user2'] = {'name': 'Jane Doe', 'age': 25}
# Retrieving data
print(db['user1']) # Output: {'name': 'John Doe', 'age': 30}
# Updating data
db['user1']['age'] = 31
# Deleting data
del db['user2']
# Searching for keys (example with regex)
print(db.keys('user.*')) # Output: ['user1']
jsonDb.py
: The core database module, implementing CRUD operations and data storage in JSON format.main.py
: An example script demonstrating how to use the JsonDB for basic data management tasks.data.json
: A sample JSON file used bymain.py
to illustrate data storage and retrieval.
Contributions to the JsonDB Project are welcome! Whether it's reporting a bug, discussing potential improvements, or contributing code, we value your input.
Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.