Skip to main content

Encrypted Async File-Based Database for Pydantic Models

Project description

BabaDB

BabaDB is a simple asynchronous database with data protection via SHA-256 hashing and a convenient API based on Pydantic models and SQLModel-like syntax.

Installation

pip install babadb

Quick Start

import asyncio
from pydantic import BaseModel
from babadb import BabaEngine, BabaTable, BabaSession

class User(BaseModel):
    name: str
    age: int

async def main():
    engine = BabaEngine("data.baba", logging="false")
    session = BabaSession(engine)
    user_table = BabaTable(User)

    async with session:
        await session.insert(user_table, User(name="Alice", age=31))
        await session.insert(user_table, User(name="Bob", age=25))
        users = await session.all(user_table)
        for user in users:
            print(user)

asyncio.run(main())

Features

  • Asynchronous sessions with async with
  • Data modeled using Pydantic for validation and type safety
  • Data stored securely as a single SHA-256 hash in .baba files
  • Configurable logging (console, file, or disabled)
  • Colored console logs for INFO (green), WARNING (yellow), and ERROR (red)

Usage

  • Create Pydantic models representing your tables
  • Instantiate BabaEngine with the storage file path and logging option
  • Use BabaSession for async database sessions
  • Use BabaTable to bind Pydantic models to tables
  • Use session methods like insert and all for data operations

Logging Options

  • "console" (default): logs printed to console with colors
  • "file": logs saved to baba_logs/ folder with timestamped filenames
  • "false": logging disabled

License

MIT 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

babadb-1.1.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

babadb-1.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file babadb-1.1.2.tar.gz.

File metadata

  • Download URL: babadb-1.1.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for babadb-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0a26da33d088596f9f1361adc9168ea90ad9790598810d354f980c43956a800c
MD5 89baa5eb92dc9fdae3f47e7b5a5209ad
BLAKE2b-256 fcb7e7014d21601a769dd4b8c253c5382ec4c43bafa09f6ae446f3462d020eb9

See more details on using hashes here.

File details

Details for the file babadb-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: babadb-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for babadb-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 538b5107ce3ddc3c62a7ae29a0ce88f700431e3e898e93fb7c18151f61f70bec
MD5 040e4f5bf4aa57ea9929a5fa03ce6c3c
BLAKE2b-256 4c85f36c04372c62f76921df86c5dca7118b471ba9b8a644061e7431753d1f63

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