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.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

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.3.tar.gz (9.2 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.3-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastjson_db-0.3.3.tar.gz
  • Upload date:
  • Size: 9.2 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.3.tar.gz
Algorithm Hash digest
SHA256 1b9636c0eefc25eece9246bef5560014577d6b9d301a160caed22c120b406685
MD5 980747afb00d308405cdcd849bf77049
BLAKE2b-256 6c7b58c2c7300ce71da4185549a8e8f08d4d407f65a41b474e7d9ba65f38cb2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastjson_db-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 10.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a507f35ecac4ef52e294d98d82d7f7328f45f2b9b43a99071869f11e0fb318f7
MD5 c091479c4114d6e28ee43f29828ac753
BLAKE2b-256 674b51ed72e009d5a02432a122f487ee125a92643168aadf5f3fb0208d08b40c

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