A lightweight JSON database with dataclass support.
Project description
FastJson-db
A lightweight JSON-based database for Python.
fastjson-db allows you to store, retrieve, and manipulate data in a simple JSON file with a minimal and easy-to-use API.
Features
- Lightweight and simple to use
- CRUD operations: insert, get, update, delete
- Automatic unique IDs for records
- Optional fast backend using
orjsonif installed - Human-readable JSON file
Installation
The currently newest version is [0.3.3].
pip install fastjson-db
Examples
Some basic examples on how to user FastJson-db
Creating a Class
To manipulate JsonTables, you need to create a JsonModel subclass (dataclass), so the JsonTable only accepts that especific JsonModel subclass.
from fastjson_db import JsonModel
from dataclasses import dataclass
@dataclass
class User(JsonModel):
_id: int
name: str = ""
password: str = ""
It's obrigatory using _id field or it will not result in error when quering.
Creating a JsonTable
JsonTables are the ones inserting and updating your dataclasses in .json files. They will automaticly create and facilitate the usage of .json "tables", trying to simulate a simple database.
from fastjson_db import JsonModel, JsonTable
from dataclasses import dataclass
@dataclass
class User(JsonModel):
_id: int = 0
name: str = ""
password: str = ""
user = User(name="Allan", password="123")
user_table = JsonTable("users.json", User)
Links
📚 Complete Docs
📝 Changelog
🛣️ Roadmap
🤝 Contributing
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 fastjson_db-0.3.4.tar.gz.
File metadata
- Download URL: fastjson_db-0.3.4.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
949dbcc512445ddc3a9aa0668a6dab8ec7d4f91eec0a9d5d7be87a767384f164
|
|
| MD5 |
e12ec9f5927d3717f507ecaf340b91ec
|
|
| BLAKE2b-256 |
3e581932f14e676544a578905a37c358b2e1e72336fec965d1cacc546c0ce21e
|
File details
Details for the file fastjson_db-0.3.4-py3-none-any.whl.
File metadata
- Download URL: fastjson_db-0.3.4-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78c30a8adc96c03d3f7235d1bc0a2822f2436d8ecbe1d60463d6e8acefb00743
|
|
| MD5 |
e6f9bfcde42f529f90c98a458387e3c1
|
|
| BLAKE2b-256 |
83708a1a8a572adb72220eb57814bfcbe79c2bf7b9d3b71e839cc0577b4310e9
|