One Model. Every Database. Advanced cross-language ORM/ODM supporting SQL, NoSQL, Vector, and Graph engines.
Project description
BullDB for Python
One Model. Every Database. Unified Security, AI, and High-Performance for Python.
BullDB is the world's most advanced cross-language ORM/ODM/Data Access Framework. This is the official Python package.
With BullDB, you define a single Active Record model class and query it seamlessly across relational SQL engines (PostgreSQL, SQLite), document stores (MongoDB), key-value stores (Redis), and vector/graph databases under a unified schema-driven interface.
Installation
Install the package via pip:
pip install bulldb
Ensure you have your environment database configs set, or use the default SQLite in-memory pool for quick starts.
Key Features
- Active Record Models: Native Python classes inheriting from
BaseModelwith clean type annotations. - Auto-Migrations: Transparent schema diffing and table modification/reconstruction.
- Zero-Dependency Field Encryption: Advanced AES-256-GCM secure field encryption with runtime key override (
set_encryption_key) and secure random fallbacks. - Cross-Language Compatibility: Standardized binary payload layout (
nonce (12b) + tag (16b) + ciphertext) allowing decryption across Python, TypeScript, Go, Rust, and C#. - Native AI Embeddings: Built-in HTTP clients for OpenAI, Gemini, and Ollama embeddings.
- Performance Cache: Transparent local TTL caching and telemetry/observability engines.
Quick Start Example
Here is a complete, ready-to-run Python example:
import asyncio
from bulldb import BaseModel, PrimaryKey, Unique, MultiDatabase, UUID, Email, EncryptedString, HashedPassword
from bulldb.migration import MigrationEngine
from bulldb.security import SecurityEngine
# 1. Define your Active Record model
class User(BaseModel):
id: UUID = PrimaryKey()
email: Email = Unique()
secret_note: str = EncryptedString()
password: str = HashedPassword()
async def main():
# 2. Setup Multi-Engine Database Connection
db = MultiDatabase()
await db.connect_all()
BaseModel.set_db(db)
# 3. Initialize and run schema migrations
migrator = MigrationEngine(db)
migrator.register_model(User)
await migrator.generate_and_apply_schema()
# 4. Optional: Override the default encryption key at runtime
# (Default: uses BULLDB_ENCRYPTION_KEY env, or generates a secure random session key)
SecurityEngine.set_encryption_key(b"my-custom-super-secret-key-32b-length")
# 5. Create and save a user
user = await User.create(
email="developer@example.com",
secret_note="This is highly confidential Python data.",
password="mySecurePassword123"
)
print(f"Created User ID: {user.id}")
# Note: Secret note is encrypted, and password is salted and hashed in the database!
print(f"Encrypted Password in DB: {user.password}")
# 6. Retrieve the user
# Fetch by ID (automatic decryption of encrypted fields on load)
fetched = await User.get_by_id(user.id)
print(f"Decrypted Secret Note: {fetched.secret_note}") # "This is highly confidential Python data."
# Find first record matching conditions
first_user = await User.find_first(email="developer@example.com")
print(f"Found User ID: {first_user.id}")
# 7. Password verification
is_valid = SecurityEngine.verify_password("mySecurePassword123", fetched.password)
print(f"Password Valid: {is_valid}") # True
# 8. Clean up / delete user
await user.delete()
print("User deleted successfully.")
await db.disconnect_all()
if __name__ == "__main__":
asyncio.run(main())
AI Embeddings & RAG Pipelines
Instantiate a RAG pipeline on your document models:
from bulldb.ai import RAGPipeline
# Define a Document model
class Document(BaseModel):
id: UUID = PrimaryKey()
text: str
vector_val: list # Stored embeddings
# Set up and ingest a document
pipeline = RAGPipeline(Document, vector_field="vector_val", text_field="text")
await pipeline.ingest_document("BullDB makes multi-language database access a breeze.")
# Query semantic similarity
results = await pipeline.query_similarity("multi-language database", limit=1)
for doc in results:
print(f"Similarity Match: {doc.text}")
License
This package is licensed under the 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
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 bulldb-1.0.15.tar.gz.
File metadata
- Download URL: bulldb-1.0.15.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45353de1e4588c1fe36816aaa3c19482f09f1dffda8b4556fd6f02238482f19a
|
|
| MD5 |
f8539fd59ecb5e1d355d08fea56694ae
|
|
| BLAKE2b-256 |
1db447d06505a27d3fbcb3b2ce525ad7e6658defe1d4758d9f58047178a4fa1a
|
Provenance
The following attestation bundles were made for bulldb-1.0.15.tar.gz:
Publisher:
publish.yml on vikukumar/bulldb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bulldb-1.0.15.tar.gz -
Subject digest:
45353de1e4588c1fe36816aaa3c19482f09f1dffda8b4556fd6f02238482f19a - Sigstore transparency entry: 1918428882
- Sigstore integration time:
-
Permalink:
vikukumar/bulldb@3aa22d41b905146659637d843c59a7e069e467d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vikukumar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3aa22d41b905146659637d843c59a7e069e467d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bulldb-1.0.15-py3-none-any.whl.
File metadata
- Download URL: bulldb-1.0.15-py3-none-any.whl
- Upload date:
- Size: 27.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4618225d5e92bfdc00d77336c9396f868c59e4e9c3e1e65156d9892b3f2e7763
|
|
| MD5 |
46b1c7feb65255c1103ad5f76dc8d19a
|
|
| BLAKE2b-256 |
9f754aba1c3cb9a7f4172f4edfaa0b079072020a3952118873695e5edf8c6290
|
Provenance
The following attestation bundles were made for bulldb-1.0.15-py3-none-any.whl:
Publisher:
publish.yml on vikukumar/bulldb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bulldb-1.0.15-py3-none-any.whl -
Subject digest:
4618225d5e92bfdc00d77336c9396f868c59e4e9c3e1e65156d9892b3f2e7763 - Sigstore transparency entry: 1918428943
- Sigstore integration time:
-
Permalink:
vikukumar/bulldb@3aa22d41b905146659637d843c59a7e069e467d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vikukumar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3aa22d41b905146659637d843c59a7e069e467d4 -
Trigger Event:
push
-
Statement type: