The Async Python ORM for Maximum Performance.

Stop choosing between ease of use and speed. KaironDB offers a fully asynchronous, declarative API powered by a Go core to run your database operations at unparalleled speed.

The KaironDB Advantage

Engineered for modern, data-intensive applications.

Truly Concurrent

Built for `async/await`. Run hundreds of queries in parallel, drastically reducing the total time to complete I/O-bound workloads.

Declarative & Safe

Define your tables with intuitive Python classes and get automatic data validation before your data even hits the database.

Powerful Querying API

Forget writing long SQL strings. Build complex queries with `AND` & `OR` conditions programmatically using an elegant, ORM-like interface.

Proven Performance

See how KaironDB's async architecture outperforms traditional sequential execution.

benchmark.py

async def run_kairondb_benchmark():
    # Creates 1000 query tasks
    tasks = [User.select(where={'id': 6}) for _ in range(1000)]
    await asyncio.gather(*tasks)

def run_pyodbc_benchmark():
    # Opens one connection and runs 1000 queries sequentially
    for _ in range(1000):
        cursor.execute(sql_query, params)
        cursor.fetchall()

> python benchmark.py

==================================================

🏁 FINAL RESULTS 🏁

==================================================

KaironDB (Concurrent): 0.8432 seconds

pyodbc (Sequential): 1.9670 seconds

--------------------------------------------------

🏆 KaironDB was 2.33x faster at completing the total workload!

Getting Started

1. Connecting to Your Database

Click a tab below to see the connection example for your database.

from kairondb import SQLBridge
bridge = SQLBridge(
    driver="sqlserver",
    server="YOUR_SERVER_IP",
    db_name="YOUR_DATABASE",
    user="YOUR_USERNAME",
    password="YOUR_PASSWORD"
)
from kairondb import SQLBridge
bridge = SQLBridge(
    driver="postgres",
    server="localhost",
    db_name="mydb",
    user="user",
    password="pass"
)
from kairondb import SQLBridge
bridge = SQLBridge(
    driver="sqlite3",
    server="./my_local_app.db",
    db_name="", user="", password=""
)

2. Define Your Model

Describe your database table using declarative Python classes.

from kairondb import Model, IntegerField, StringField

class User(Model):
    _table_name = "users"
    id = IntegerField(primary_key=True)
    username = StringField(required=True)

3. Run Async Queries

All database operations are now asynchronous. Remember to associate your models with the bridge and run your code with `asyncio`.

import asyncio

async def main():
    # ... (Bridge connection code from step 1)
    Model.set_bridge(bridge)

    # Fetch users with status 'active' and ID > 100
    results = await User.select(where={
        'status': 'active',
        'id__gt': 100
    })
    print(results)
    
    await bridge.close()

if __name__ == "__main__":
    asyncio.run(main())

Advanced Usage

Complex Queries with `Q` Objects

Use `Q` objects to build complex `AND` (`&`) and `OR` (`|`) conditions programmatically.

from kairondb import Q

# Find active users who are either under 25 OR whose name starts with 'J'
query = Q(status='active') & (Q(age__lt=25) | Q(username__like='J%'))
results = await User.select(where=query)

Concurrent Queries

Run hundreds of queries in parallel using `asyncio.gather` for massive throughput improvements.

user_ids = range(1, 101)
tasks = [User.select(where={'id': uid}) for uid in user_ids]
all_users = await asyncio.gather(*tasks)