Skip to main content

dqlite-client

Async Python client for dqlite, Canonical's distributed SQLite. It connects to a dqlite cluster, finds the current Raft leader, runs SQL, and pools connections.

The API is inspired by asyncpg's ergonomics — explicit connect() / create_pool(), fetch / fetchall / fetchval, and context-manager transactions — with a deliberately simple data model: fetch returns list[dict], fetchall returns list[list], fetchval returns a scalar. There is no Record type.

Is this the package you want?

Use dqlite-client directly when you want a lightweight async client with no ORM or DB-API layer, or when you need fine-grained control over cluster bootstrapping and the wire protocol.

If you want a standard PEP 249 driver, SQLAlchemy, Alembic, or most ORMs, reach for a higher layer instead — see The dqlite Python stack below.

Installation

pip install dqlite-client

Requires Python 3.13+.

Usage

import asyncio
from dqliteclient import connect

async def main():
    conn = await connect("localhost:9001")
    async with conn.transaction():
        await conn.execute("CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)")
        await conn.execute("INSERT INTO t (name) VALUES (?)", ["hello"])
        rows = await conn.fetch("SELECT * FROM t")   # list[dict]
        for row in rows:
            print(row)
    await conn.close()

asyncio.run(main())

Connection pool

from dqliteclient import create_pool

pool = await create_pool(["localhost:9001", "localhost:9002", "localhost:9003"])
async with pool.acquire() as conn:
    rows = await conn.fetch("SELECT 1")

The dqlite Python stack

This is one of four layered packages. Each builds on the one below:

Package Role
sqlalchemy-dqlite SQLAlchemy 2.0 dialect
dqlite-dbapi PEP 249 (DB-API 2.0) driver — sync & async
dqlite-client — this package Async wire client — pooling, leader discovery
dqlite-wire Wire-protocol codec

For SQLAlchemy/ORM use, prefer sqlalchemy-dqlite or dqlite-dbapi.

Documentation

  • Architecture — layering, the connection lifecycle (a connection that loses its session is closed for good), transaction tracking, leader discovery and the pool.
  • Connection pooling — sizing, startup, and leader behavior.
  • Deployment: forking & multiprocessing — read this if you use gunicorn, Celery, or multiprocessing.
  • dqliteclient.sql — the lexical SQL helpers (comment stripping, top-level statement splitting) the client and the dbapi layer share.
  • Data types & NULL handling — the row model and a server-version gotcha for NULLs in typed columns.

Development

See DEVELOPMENT.md for setup and contribution guidelines.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dqlite_client-0.7.0.tar.gz (149.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dqlite_client-0.7.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file dqlite_client-0.7.0.tar.gz.

File metadata

  • Download URL: dqlite_client-0.7.0.tar.gz
  • Upload date:
  • Size: 149.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dqlite_client-0.7.0.tar.gz
Algorithm Hash digest
SHA256 08e4ade9debcc66cd341bc5b06183477d04ddea88c3312df3dc3519ce26ce65c
MD5 d98d6c9c27e309fac8268ada3a9876f2
BLAKE2b-256 42937b1f8f643f1f7cf6a83decd56ca076130ac50e682d3f2837faecf0c8b952

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_client-0.7.0.tar.gz:

Publisher: publish-to-pypi.yml on letsdiscodev/python-dqlite-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dqlite_client-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: dqlite_client-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dqlite_client-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2011023a9be5666fba8487bf4342f7b58dfd7cb6f16ad52a83ad6df5d4c9d2fc
MD5 5b3bda0596c94d5440a7c71293266336
BLAKE2b-256 7fdc3e8b0726c1b79178a0f5cde9bd0cdfa882d189d54b1eeef1259a5596d595

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_client-0.7.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on letsdiscodev/python-dqlite-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.0

2 files

This release

0.7.0 This release

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

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