Skip to main content

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 orjson if installed
  • Human-readable JSON file

Installation

The currently newest version is [0.3.5].

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

PyPI License

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

fastjson_db-0.3.5.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

fastjson_db-0.3.5-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file fastjson_db-0.3.5.tar.gz.

File metadata

  • Download URL: fastjson_db-0.3.5.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fastjson_db-0.3.5.tar.gz
Algorithm Hash digest
SHA256 37ae8b89b1e8fa5bea029e39d41bcec7ac6da8fa230deca89fe7f49e12d837d1
MD5 9efdc053ce3689224b9ba9f5a1ac29c0
BLAKE2b-256 99956fcf7f85e2f1051d4d580074f7881f7692182262eaf35a4081130f2ba883

See more details on using hashes here.

File details

Details for the file fastjson_db-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: fastjson_db-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fastjson_db-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 376ef5122fd72358f8aeaa2193da4a44dd92257a8f5e42cfc5b605b933f7e4ef
MD5 f709926d27a0998ba54dfd57a82d6d5a
BLAKE2b-256 79f8323944b84d0f92a83c45469f8695169f0f4d5671ce2e6d90307b0815b4da

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