Skip to main content

vanilladatabase

Official Python client SDK for VanillaDatabase (VanillaDB) — Zero-configuration, multi-tenant SQLite Cloud Database Engine with Realtime Server-Sent Events (SSE), Media Storage (HTTP 206 Byte-Range Streaming), AI Vector Cosine Similarity Search, Atomic Batch Transactions, and Table CRUD Query Builders.

PyPI version License: MIT


📦 Installation

pip install vanilladatabase

⚡ Quick Start

import os
from vanilladb import VanillaDatabase

# 1. Initialize with Unified Database Base URL & Master API Token
db = VanillaDatabase(
    url=os.getenv("VANILLA_DB_URL", "http://localhost:3000/v1/databases/db_your_database_id"),
    token=os.getenv("VANILLA_DB_TOKEN", "vdb_live_your_api_token_here")
)

📖 Feature Reference

1. Fluent Table CRUD Query Builder

Perform operations without writing raw SQL statements:

# 🟢 Insert row
insert_res = db.table("users").insert({
    "username": "elaina",
    "score": 100
})
print("Inserted ID:", insert_res.get("lastInsertRowid"))

# 🔍 Select rows with filtering, ordering, pagination
result = db.table("users").select(
    limit=10,
    offset=0,
    order_by="score",
    order="DESC"
)
print("Top Users:", result["rows"])

# 🟡 Update row(s)
db.table("users").update(
    where={"id": 1},         # Condition (WHERE)
    values={"score": 250}    # Fields to update (SET)
)

# 🔴 Delete row(s)
db.table("users").delete({"id": 1})

2. Parameterized SQL Execution

Execute any SQLite SQL statement safely using parameterized binding:

# Parameterized SELECT query
query_res = db.query(
    "SELECT id, username, score FROM users WHERE score >= ? ORDER BY score DESC LIMIT ?",
    [50, 10]
)

print("Rows:", query_res["rows"])
print("Duration:", f"{query_res['durationMs']}ms")

3. ACID Atomic Batch Transactions

Execute multiple statements atomically in a single network round-trip. If any statement fails, the entire transaction rolls back:

batch_result = db.batch([
    {
        "sql": "UPDATE accounts SET balance = balance - ? WHERE id = ?",
        "params": [50.0, 1]
    },
    {
        "sql": "UPDATE accounts SET balance = balance + ? WHERE id = ?",
        "params": [50.0, 2]
    },
    {
        "sql": "INSERT INTO audit_logs (event, timestamp) VALUES (?, ?)",
        "params": ["transfer_completed", 1700000000]
    }
], transaction=True) # transaction=True guarantees ACID atomicity

print("Total Duration:", f"{batch_result['totalDurationMs']}ms")

4. AI Vector Search (Cosine Similarity & RAG)

VanillaDatabase includes native SQLite scalar functions for vector similarity matching:

matches = db.vector_search(
    table="document_embeddings",
    vector_column="embedding",
    vector=[0.012, 0.421, -0.198, 0.087], # Vector embedding list
    limit=5,
    threshold=0.75                        # Minimum similarity score (0.0 to 1.0)
)

for doc in matches:
    print(f"Doc #{doc['id']} - Similarity: {doc['similarity']}")

5. Realtime Server-Sent Events (SSE)

Subscribe to real-time table mutations (insert, update, delete, schema):

def handle_event(event):
    print(f"[Realtime {event.get('type')}] Table: {event.get('table')}", event.get("data"))

# Blocking subscription loop (runs in current thread or daemon thread)
# db.subscribe(handle_event, table="users")

6. Scoped Media Storage & HTTP 206 Streaming

Upload, stream, and delete media files tied directly to your database instance:

# Upload local file
file_record = db.upload_file(
    file_path="./video.mp4",
    filename="video.mp4",
    content_type="video/mp4"
)
print("File ID:", file_record["id"])

# Get streaming URL (Supports HTTP 206 Partial Content Range)
stream_url = db.get_file_url(file_record["id"])
print("Streaming URL:", stream_url)

# Delete file
db.delete_file(file_record["id"])

🛡️ Production & Reliability Best Practices

  1. Timeout Setting: Set appropriate client timeouts (30s to 60s) for background workers or sweep tasks.
  2. Indexing: Always create composite indexes on columns queried frequently (e.g. CREATE INDEX IF NOT EXISTS idx_users_status_created ON users(status, created_at);).
  3. Keep-Alive: Reuse requests sessions for HTTP Keep-Alive socket connection pooling.

📄 License

MIT © VanillaDatabase

Metadata

Release files for vanilladatabase 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vanilladatabase 1.3.2
File Size Uploaded Provenance Actions
vanilladatabase-1.3.2.tar.gz 5.5 kB Without provenance Details for vanilladatabase-1.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vanilladatabase 1.3.2
File Interpreter ABI Platform Actions
vanilladatabase-1.3.2-py3-none-any.whl Python 3 none any Details for vanilladatabase-1.3.2-py3-none-any.whl

Total release size: 11.1 kB

Release files / vanilladatabase-1.3.2.tar.gz

Download URL vanilladatabase-1.3.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e0fae388954903a586471398eeef15e7ced3e8c68e0073a0faec75a00871654
BLAKE2b-256 checksum
How to use checksums
491b537a47bbb84e71afa4e4c8fd48bd6cfa9aac1e0a9e001a1e254a08e1957a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / vanilladatabase-1.3.2-py3-none-any.whl

Download URL vanilladatabase-1.3.2-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62852ff0ce44ee5103c9ffa0828dd099a466ddeeda23c9222c3726af89bfeaaa
BLAKE2b-256 checksum
How to use checksums
84514b063b2558445793c49731d71207619009061c523d9fbc226cac50a08024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for vanilladatabase 1.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page