Skip to main content

dqlite-dbapi

A PEP 249 (DB-API 2.0) driver for dqlite, Canonical's distributed SQLite. If you have used Python's standard sqlite3 module, this will feel familiar — same connect() / cursor() / execute() / fetchone() shape — but it talks to a replicated dqlite cluster over the network instead of a local file.

It comes in two flavors from one package: a synchronous API (dqlitedbapi) and an async API (dqlitedbapi.aio).

Is this the package you want?

Yes, if you want a drop-in-style database driver for dqlite — directly, or under a tool that expects a DB-API 2.0 driver. For SQLAlchemy specifically, use sqlalchemy-dqlite (it builds on this package).

Installation

pip install dqlite-dbapi

Requires Python 3.13+.

Usage

Sync

import dqlitedbapi

conn = dqlitedbapi.connect("localhost:9001")
cur = conn.cursor()
cur.execute("SELECT 1")
print(cur.fetchone())
conn.close()

Async

import asyncio
from dqlitedbapi.aio import aconnect

async def main():
    conn = await aconnect("localhost:9001")
    cur = conn.cursor()
    await cur.execute("SELECT 1")
    print(await cur.fetchone())
    await conn.close()

asyncio.run(main())

Key facts

  • apilevel = "2.0", paramstyle = "qmark" (? placeholders), threadsafety = 2.
  • Autocommit by default. Unlike stdlib sqlite3, the driver does not auto-BEGIN before a statement — wrap writes in an explicit transaction when you need atomic multi-statement semantics. See Transactions.
  • Isolation is always SERIALIZABLE — every write goes through Raft consensus, every read is serializable.

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 — this package PEP 249 (DB-API 2.0) driver — sync & async
dqlite-client Async wire client — pooling, leader discovery
dqlite-wire Wire-protocol codec

Using SQLAlchemy or an ORM? Prefer sqlalchemy-dqlite.

Documentation

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_dbapi-0.4.0.tar.gz (140.8 kB view details)

Uploaded Source

Built Distribution

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

dqlite_dbapi-0.4.0-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file dqlite_dbapi-0.4.0.tar.gz.

File metadata

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

File hashes

Hashes for dqlite_dbapi-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2c6b540b2ca04d2b2b011273f2a7acb9259f0a195137cb1d34674c38a3d802d3
MD5 684b109602d5e3e4f07b0669b53e2d7b
BLAKE2b-256 21272f8f19a350b51b25758e5854ca5c8dad2c49594d238502562cfab02ed071

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_dbapi-0.4.0.tar.gz:

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

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_dbapi-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: dqlite_dbapi-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 36.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_dbapi-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb2075b7bc01e52c6a31edc515b56ddf254e2ad107d93a47250ce1ba765fcfb0
MD5 2d74d3ad17194caa0773aeb44fc7a2f7
BLAKE2b-256 49b0355d41fb8b8da03b6dd8bb7ad7e15a7a496960c902e356a861112d22f041

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_dbapi-0.4.0-py3-none-any.whl:

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

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

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

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