Skip to main content

☕ CoffeeQL

One syntax. Any database.

PyPI version License: Proprietary pip package

CoffeeQL speaks every database: write one expressive, chain-based query and run it across PostgreSQL, MongoDB, MySQL, and Redis, straight from Python. Put coffeeql-server in between and it also keeps AI off your database: agents talk to CoffeeQL, and every change they make is recorded and undoable.
Powered by a blazing-fast Rust parse-and-plan engine, executed natively via Python async adapters.

Website • npm • pip (PyPI)


✨ Why CoffeeQL?

Most modern applications talk to three or more databases. You end up writing raw SQL for Postgres, pymongo pipelines for MongoDB, and redis-py commands for Redis battling different APIs, error handling paradigms, and mental models.

CoffeeQL abstracts this friction. It provides one unified syntax that compiles down to the exact query required for each underlying database, with a high-performance Rust engine handling the heavy lifting of parsing and query planning.

📦 Installation

Install the core package via pip or include specific database adapters:

pip install coffeeql
pip install coffeeql[postgres]   # asyncpg
pip install coffeeql[mongodb]    # motor
pip install coffeeql[mysql]      # aiomysql
pip install coffeeql[redis]      # redis-py

# Or install everything at once
pip install coffeeql[all]        

📖 The Syntax & Canonical Aliases

CoffeeQL supports both standard SQL canonical keywords and expressive CoffeeQL primitives:

Canonical SQL Alias CoffeeQL Primitive Target Database
users[] users[] (Table) PostgreSQL / MySQL / SQLite
products{} products{} (Collection) MongoDB
session:id{} session:id{} (Hash Key) Redis
.where(...) .where(...) Filter / Condition
.select(...) .give(...) Select specific fields
.sort(field, DESC) .sort(field, DESC) Order by
.limit(10) .cup(10) Limit results
.offset(5) .skip(5) Pagination offset
.group_by(field) .blend(field) Group by
.mix(... ON ...) .mix(... ON ...) Join / Cross-DB Federation
.insert({...}) .pour({...}) Insert
.update({...}) .refill({...}) Update
.delete() .spill() Delete
.similar(query) .vector_match() Vector Cosine Similarity

🔒 Safe Parameterized Queries (Anti-Injection)

Always pass user inputs as parameters rather than string concatenation:

import coffeeql as cql

# Positional parameter binding ($1, $2):
users = cql.query("users[].where(plan = $1 and age >= $2).select(id, name)", "pro", 21)

# Named parameter binding ($plan):
users = cql.query("users[].where(plan = $plan)", params={"plan": "pro"})

# Canonical CRUD helpers:
cql.insert("users", {"name": "Alice", "plan": "pro"})
cql.update("users", "id = 1", {"plan": "enterprise"})
cql.delete("users", "id = 99")

🚀 Quick Start (FastAPI Example)

CoffeeQL integrates beautifully into asynchronous Python stacks like FastAPI.

from fastapi import FastAPI
from coffeeql import CoffeeQL, PostgresAdapter, MongoAdapter

app = FastAPI()

# Initialize unified orchestration
db = CoffeeQL({
    'users[]':    PostgresAdapter(uri='postgresql://user:pass@localhost/mydb'),
    'products{}': MongoAdapter(uri='mongodb://localhost:27017', db='shop'),
})

@app.on_event('startup')
async def startup():
    await db.connect()

@app.get('/users')
async def get_users():
    result = await db.query('''
        users[]
            .where(plan = "pro", active = true)
            .give(name, email, balance)
            .sort(balance, DESC)
            .cup(20)
    ''').run()
    return result.rows

Because CoffeeQL queries across multiple architectures, testing locally is easiest with a unified container stack. You can spin up Postgres, Mongo, and Redis instantly using a standard docker-compose.yml to test your cross-database joins natively before pushing to production via pip.


🧠 Advanced Features

Cross-Database Federation (Experimental)

Join a PostgreSQL table with a MongoDB collection in memory, automatically handled by the engine.

@app.get('/dashboard')
async def dashboard():
    result = await db.query('''
        users[]
            .where(active = true)
            .mix(products{} ON users[].id = products{}.user_id)
            .give(users[].name, products[].title, products[].price)
            .sort(products[].price, DESC)
            .cup(10)
    ''').run()
    return result.rows

Resiliency: Timeout, Retry, & Partial States

Built for the real world, where networks drop and databases stall.

# Fail fast if a DB is slow
await db.query('users[].cup(100)').timeout(3000).run()

# Retry on flaky connections
await db.query('products{}.where(active = true)').retry(3).run()

# Accept partial results if a federated node goes down
await db.query('users[].mix(products{} ON ...)').partial().run()

Explain & Validate (Zero Dependencies)

Inspect execution plans without making a single database call.

from coffeeql import explain

plan = explain('''
    users[]
        .where(plan = "pro")
        .mix(products{} ON users[].id = products{}.user_id)
        .cup(10)
''')
print(plan.rendered)

Output:

# CoffeeQL Execution Plan
#   Step 1 → PostgreSQL   SCAN    users[]       WHERE plan='pro'
#   Step 2 → MongoDB      SCAN    products{}
#   Step 3 → Memory       HASH JOIN              ON users[].id = products{}.user_id
#   Step 4 → Memory       LIMIT   10
#
#   Adapters: 2  ·  Strategy: in-memory hash join  ·  Concurrent fetch: yes

🏗️ Architecture Layer

The Rust core is the exact same engine that powers the npm package guaranteeing 100% parity across languages for parsing, planning, and explain outputs.

graph TD;
    A[Your CoffeeQL Query] -->|String| B(Rust Engine via PyO3);
    B -->|Parse & Plan - Fast, Zero-Copy| C(Python Execution Layer);
    C -->|Reads Plan| D{Native Async Adapters};
    D -->|asyncpg| E[(PostgreSQL)];
    D -->|motor| F[(MongoDB)];
    D -->|aiomysql| G[(MySQL)];
    D -->|redis-py| H[(Redis)];
    E & F & G & H --> I[Real Rows Returned];

📦 What's in v0.3.0

  • coffeeql.parse() → Parse and validate any CoffeeQL query.
  • coffeeql.is_valid() → Boolean validation.
  • coffeeql.explain() → Human-readable execution plan.
  • CoffeeQL class → Core client for connect, query, and explain.
  • All 4 adapters stable: PostgreSQL, MongoDB, MySQL, Redis.
  • .timeout(), .retry(), .partial() resilience modifiers.
  • Cross-adapter federation (Experimental).

📄 License & Support

CoffeeQL is Proprietary software. Copyright © 2026 Khushvi Bamrolia. All rights reserved. Use is governed by the CoffeeQL Terms of Service.

Metadata

Release files for coffeeql 1.0.9

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

Built distributions (wheels)

Table of built distributions (wheels) for coffeeql 1.0.9
File Actions
coffeeql-1.0.9-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for coffeeql-1.0.9-cp39-abi3-win_amd64.whl
coffeeql-1.0.9-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for coffeeql-1.0.9-cp39-abi3-manylinux_2_28_x86_64.whl
coffeeql-1.0.9-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for coffeeql-1.0.9-cp39-abi3-manylinux_2_28_aarch64.whl
coffeeql-1.0.9-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64 Details for coffeeql-1.0.9-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 2.0 MB

Release files / coffeeql-1.0.9-cp39-abi3-win_amd64.whl

Download URL coffeeql-1.0.9-cp39-abi3-win_amd64.whl
Size 330.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
81ad3012dddc2162d47c8103331e045472db32daa8012e1b334df622eccccf8f
BLAKE2b-256 checksum
How to use checksums
47057e95ad8200c8b737497d853eab84519985b0209724e64a092b31519c588f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / coffeeql-1.0.9-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL coffeeql-1.0.9-cp39-abi3-manylinux_2_28_x86_64.whl
Size 424.9 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
4d088d7c61425e3450a5641739cf7571b44b22e81ee76a5aff727a60ea34f4a7
BLAKE2b-256 checksum
How to use checksums
0e3c2fc67c92d9aa2c34acfc3a03821a4858ee732feefe8af2abe3e0024f0af3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / coffeeql-1.0.9-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL coffeeql-1.0.9-cp39-abi3-manylinux_2_28_aarch64.whl
Size 410.9 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a99ab1a33c49d8c9141c2f530cb29c41eac973542cc87c8699ea58f25fd1fd29
BLAKE2b-256 checksum
How to use checksums
d4877c36fd7c448fd8282dd5e89acd3211fe6550d63e291fa93bf885533cbb75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / coffeeql-1.0.9-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL coffeeql-1.0.9-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 809.0 kB
Tags CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
985372305bfc2dc4fc46cd02493ca2c11fad91bf52fe4ae452e8c32910d1ee9e
BLAKE2b-256 checksum
How to use checksums
02026356c07eacd2b614e90cec6cd226ee897ae8cdfc4a0040e5889977faf21e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for coffeeql 1.0.9

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