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
.babafiles - 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
BabaEnginewith the storage file path and logging option - Use
BabaSessionfor async database sessions - Use
BabaTableto bind Pydantic models to tables - Use session methods like
insertandallfor data operations
Logging Options
"console"(default): logs printed to console with colors"file": logs saved tobaba_logs/folder with timestamped filenames"false": logging disabled
License
MIT License
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
babadb-1.1.2.tar.gz
(3.5 kB
view details)
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a26da33d088596f9f1361adc9168ea90ad9790598810d354f980c43956a800c
|
|
| MD5 |
89baa5eb92dc9fdae3f47e7b5a5209ad
|
|
| BLAKE2b-256 |
fcb7e7014d21601a769dd4b8c253c5382ec4c43bafa09f6ae446f3462d020eb9
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
538b5107ce3ddc3c62a7ae29a0ce88f700431e3e898e93fb7c18151f61f70bec
|
|
| MD5 |
040e4f5bf4aa57ea9929a5fa03ce6c3c
|
|
| BLAKE2b-256 |
4c85f36c04372c62f76921df86c5dca7118b471ba9b8a644061e7431753d1f63
|