A session-scoped self-adaptive database framework for logical object-oriented data management.
Project description
ChiralDB
ChiralDB is an autonomous, session-scoped database framework that transparently bridges the gap between Relational (SQL) and Document (JSONB) paradigms over a single PostgreSQL instance.
Instead of defining strict schemas or maintaining a separate MongoDB cluster for unstructured data, ChiralDB completely abstracts storage placement, schema evolution, and SQL JOINs away from the developer.
⚡ Key Features
- Zero Schema Definition: Ingest raw JSON. ChiralDB uses Shannon Entropy to autonomously infer data types and split repeating arrays into highly normalized SQL tables.
- Hybrid Storage Engine: Flat, stable scalars go to SQL columns. Drift-prone, heavily nested, or sparse data gracefully spills over into
JSONBautomatically. - Logical Session Isolation: Data is physically stored in the same tables, but logically separated by
session_id. - ACID Transactions: No Two-Phase Commit (2PC) overhead. By utilizing PostgreSQL's JSONB alongside relational tables with
begin_nested(), we achieve perfect Atomicity and Isolation across paradigms. - Built-in Dashboard: Ships with a React SPA to visualize your logical schemas and execute CRUD operations.
🛠️ Quick Start
Installation
pip install chiral-db
Start the Server & Dashboard
ChiralDB ships with a built-in FastAPI server and React Dashboard. Just provide your PostgreSQL credentials in a .env file and run:
chiral serve --port 8000
Open http://localhost:8000 in your browser to access the interactive Query Executor.
Programmatic Usage
You can use ChiralDB natively in your Python asyncio applications. You don't write DDL. You don't write SQL. You just use data.
import asyncio
from chiral.client import ChiralClient
async def main():
async with ChiralClient("postgresql+asyncpg://user:pass@localhost:5432/db") as db:
# 1. Ingest arbitrary, schema-less data
await db.ingest(
session_id="experiment_01",
data={
"username": "devansh",
"sensors": [{"type": "temp", "val": 22}, {"type": "humid", "val": 40}]
}
)
# 2. Query it logically. ChiralDB handles the SQL Joins and JSONB unpacking!
result = await db.query({
"operation": "read",
"session_id": "experiment_01",
"select": ["username", "sensors.val"],
"filters": [{"field": "sensors.val", "op": "gt", "value": 20}]
})
print(result["rows"])
if __name__ == "__main__":
asyncio.run(main())
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
### Step 3: Update PyPI with the new README
Because PyPI packages are immutable, you must bump the version number to push the new README to the website.
1. Open `pyproject.toml` and change `version = "1.0.0"` to `version = "1.0.1"`.
2. Rebuild and publish:
```bash
uv build
uv publish
(Go check your package on PyPI right after this—it will look incredible!)
Step 4: Push to GitHub & Deploy the Website
MkDocs has a magical built-in command that automatically compiles your documentation into HTML and pushes it to a special gh-pages branch on your GitHub repository. GitHub then hosts this branch for free!
1. Update repo_url in mkdocs.yml
Open mkdocs.yml and update the repo_url at the top to point to your actual GitHub repository:
repo_url: https://github.com/your-username/chiral-db
2. Commit and Push your code to GitHub:
git add .
git commit -m "feat: Finalize PyPI package, README, and MkDocs setup"
git push origin main
3. Deploy the Website: Run this single command in your terminal:
uv run mkdocs gh-deploy --force
(This command builds the site and pushes it to the gh-pages branch on GitHub).
4. Turn on GitHub Pages:
- Go to your repository on GitHub.com.
- Click on the Settings tab.
- Click on Pages in the left sidebar.
- Under "Build and deployment", set the Source to Deploy from a branch.
- Under "Branch", select
gh-pagesand click Save.
Wait about 60 seconds, and your website will be live at https://<your-username>.github.io/chiral-db/! Make sure to update the placeholder link in your README.md to point to the real URL.
Let me know when the site is live! You have officially completed the entire lifecycle of a production-grade software project!
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 chiral_db-1.0.1.tar.gz.
File metadata
- Download URL: chiral_db-1.0.1.tar.gz
- Upload date:
- Size: 450.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4098f8987a0b9206e2959326d797689f92ff8c7ad0247a40dd5126077daa688
|
|
| MD5 |
0ab5bee78cc6e0a0c0b8ec3600b20b66
|
|
| BLAKE2b-256 |
142640d04a6d68f128c0ce6b9b2d2d6184759b9644cc0819da833d83a01f2657
|
File details
Details for the file chiral_db-1.0.1-py3-none-any.whl.
File metadata
- Download URL: chiral_db-1.0.1-py3-none-any.whl
- Upload date:
- Size: 56.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f6c166472484485a34f512d304de2b2560ccebd1b2262546d3cb5c85460e910
|
|
| MD5 |
1724c6ea37c3cb616e992c8a978a657b
|
|
| BLAKE2b-256 |
6a39b78e09e461883ada771b40ec825f49445dd6cf0d9a7dd2cfd779ad3bf9ca
|