A simple JSON-based ORM for Python
Project description
JSON2ORM
A lightweight JSON-based ORM for Python 🚀
No SQL, no external DB engine — just plain JSON files acting like a database.
Perfect for small projects, testing, prototyping or educational purposes.
✨ Features
- Define models like in Django ORM or Prisma
- Auto-increment IDs for each model
- Basic CRUD support (
create,all,get,save,delete) - Simple JSON file storage, no setup required
- Human-readable database (
.jsonfile)
📦 Installation
pip install json2orm
⚡ Quick Start Example
from json2orm import Database, Model
# Setup database (JSON file)
db = Database("mydb.json")
# Define models
class User(Model):
table_name = "users"
class Post(Model):
table_name = "posts"
# Create users
u1 = User.create(name="Ali", email="ali@test.com")
u2 = User.create(name="Sara", email="sara@test.com")
print([u.name for u in User.all()]) # ➝ ['Ali', 'Sara']
# Get user
ali = User.get(name="Ali")
print(ali.email) # ➝ ali@test.com
# Update user
ali.email = "ali_updated@test.com"
ali.save()
print(User.get(id=1).email) # ➝ ali_updated@test.com
# Delete user
u2.delete()
print([u.name for u in User.all()]) # ➝ ['Ali']
# Create posts
p1 = Post.create(title="First Post", content="Hello World", user_id=ali.id)
p2 = Post.create(title="Second Post", content="Next Post", user_id=ali.id)
print([p.title for p in Post.all()]) # ➝ ['First Post', 'Second Post']
🔮 Roadmap / Future Features
JSONORM is in its early stages. Planned features include:
- Field definitions in models (like Django
models.CharField,IntegerField, etc.) - Schema validation (prevent invalid fields)
- Query filters (e.g.,
User.filter(age__gt=18)) - Export database (to CSV, SQLite, MongoDB, etc.)
- Simple GUI for browsing and editing JSON-based data
- CLI tool to manage database & migrations
- Relationships (OneToMany / ManyToMany)
🧪 Running Tests
You can run the provided example tests:
python examples/test_example.py
Expected output is included as comments in the file.
📜 License
This project is licensed under the MIT License.
Feel free to use, modify and distribute.
❤️ Contributing
PRs are welcome! Ideas, bug reports, and feature requests are highly appreciated.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json2orm-0.1.0.tar.gz.
File metadata
- Download URL: json2orm-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3740d3fed6be8c1e2b0bce729c41ae21c99e7d7d8ee059e7ac478e59c039243
|
|
| MD5 |
6e60979cde8c00a713c76c5d55a6a317
|
|
| BLAKE2b-256 |
2a5be4bd07f9f11171ba07bb29d32133ebaf7e92f582f2a381af7cae469fa04a
|
File details
Details for the file json2orm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: json2orm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1785a6d5b4b6ce68c5b76d31555c949968cb885368331244ad573f0ed22a1925
|
|
| MD5 |
a436f1f050985d12bc7c22d64b4b518f
|
|
| BLAKE2b-256 |
5fb13769ddd384b8a656e72ea7d7ba4cdaa433843ac927a270604947c8b7cc72
|