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.5.0.tar.gz (160.0 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.5.0-py3-none-any.whl (49.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dqlite_client-0.5.0.tar.gz
  • Upload date:
  • Size: 160.0 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.5.0.tar.gz
Algorithm Hash digest
SHA256 d7ea2821660d06bf91e27eb50a9efabc5749960b0b2b393782cc2ed4b1520940
MD5 eca61b6bcad5efdc479288eb2b631432
BLAKE2b-256 e055ccf2712c63eecc47550b6b626cc3faf1cbde1963fde77b7f5ffee3bff8e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_client-0.5.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.5.0-py3-none-any.whl.

File metadata

  • Download URL: dqlite_client-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 49.5 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 327c810b08be8560b179b3b9cdf139074b226b9517bcc2b63efb6a8c03f248b5
MD5 ccf33cc5e349d7a07e5b84ed8a3d91f7
BLAKE2b-256 4a4dcd6638de092cf8c176f7ff6cba57c0e649ac1f41ede228a140baf762cdb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_client-0.5.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

0.7.0

2 files

0.6.0

2 files

This release

0.5.0 This release

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