Skip to main content

Python bindings for SQLRite — a small, embeddable SQLite clone written in Rust.

Project description

sqlrite (Python)

Python bindings for SQLRite — a small, embeddable SQLite clone written in Rust. Shape follows PEP 249 / the stdlib sqlite3 module, so most callers can pick it up without reading the docs.

Install

# From PyPI:
pip install sqlrite

# From source in a clone of the repo:
pip install maturin
cd sdk/python
maturin develop --release

Quick tour

import sqlrite

# File-backed or in-memory (use `":memory:"` to match sqlite3 convention).
conn = sqlrite.connect("foo.sqlrite")
# conn = sqlrite.connect(":memory:")

cur = conn.cursor()
cur.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)")
cur.execute("INSERT INTO users (name, age) VALUES ('alice', 30)")
cur.execute("INSERT INTO users (name, age) VALUES ('bob', 25)")

cur.execute("SELECT id, name, age FROM users")
for row in cur:
    print(row)  # (1, 'alice', 30), then (2, 'bob', 25)

# Column metadata (PEP 249 `.description`):
for col in cur.description:
    print(col[0])  # 'id', 'name', 'age'

conn.close()

Transactions

with sqlrite.connect("foo.sqlrite") as conn:
    cur = conn.cursor()
    cur.execute("BEGIN")
    cur.execute("INSERT INTO users (name) VALUES ('carol')")
    if looks_good:
        conn.commit()
    else:
        conn.rollback()
# The context manager automatically commits on clean exit
# and rolls back on exception, then closes the connection.

Read-only access

conn = sqlrite.connect_read_only("foo.sqlrite")
# Any write raises sqlrite.SQLRiteError. Multiple read-only
# connections on the same file coexist (shared OS lock).

API surface

Function / Method Purpose
sqlrite.connect(db) Open or create a file-backed DB (or :memory:)
sqlrite.connect_read_only(db) Open an existing file with a shared lock
Connection.cursor() Returns a new Cursor
Connection.execute(sql, ...) Shortcut for cursor().execute(...)
Connection.commit() / .rollback() Close the current transaction
Connection.close() Drop the connection (releases OS file lock)
Connection.in_transaction bool — inside a BEGIN … COMMIT/ROLLBACK
Connection.read_only bool — opened via connect_read_only
Cursor.execute(sql, params=None) Run one statement
Cursor.executemany(sql, seq) DB-API placeholder (params deferred)
Cursor.executescript(sql) ;-separated batch of statements
Cursor.fetchone() Next row as a tuple, or None
Cursor.fetchmany(size=None) Up to size more rows as a list of tuples
Cursor.fetchall() All remaining rows
Cursor.description PEP 249 7-tuples per column (name + Nones)
Cursor.rowcount -1 (not tracked yet — returns as PEP 249 says)
iter(cursor) for row in cursor: …
sqlrite.SQLRiteError All engine failures bubble up as this

Parameter binding

execute(sql, params) accepts None and empty tuples/lists for DB-API compatibility, but any non-empty params raises TypeError with a clear message — the underlying engine doesn't support prepared-statement parameter binding yet (deferred to Phase 5a.2). For now, inline values into the SQL (with manual escaping).

Running the tests

maturin develop
python -m pytest tests/

How this ships

  • PyO3 (abi3-py38) for the Rust-Python boundary — one wheel works on every CPython 3.8+ release, no per-version rebuild.
  • maturin as the build backend, emitting standard .whl files that pip can install directly.
  • Phase 6f's CI publishes abi3-py38 wheels to PyPI for manylinux x86_64/aarch64, macOS aarch64, and Windows x86_64 (plus an sdist) on every release. OIDC trusted publishing — no long-lived PyPI token in the repo.

Status

Phase 5c MVP: ✅ — basic CRUD, transactions, context managers, read-only mode, iteration. Parameter binding, CursorRow namedtuples, and type converters (datetime, Decimal) are natural follow-ups.

Project details


Download files

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

Source Distribution

sqlrite-0.1.15.tar.gz (831.6 kB view details)

Uploaded Source

Built Distributions

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

sqlrite-0.1.15-cp38-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

sqlrite-0.1.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

sqlrite-0.1.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

sqlrite-0.1.15-cp38-abi3-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file sqlrite-0.1.15.tar.gz.

File metadata

  • Download URL: sqlrite-0.1.15.tar.gz
  • Upload date:
  • Size: 831.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlrite-0.1.15.tar.gz
Algorithm Hash digest
SHA256 f3ff462d4371ebbe31badcf4867d6699f69b9c724e0e264f16423f4725045cd2
MD5 0ee78c0aa820186189684222a6b91047
BLAKE2b-256 ef14fa3aa4bc96dc306a3964cba630e860f448b1595ebce1704c8dbf739fa948

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlrite-0.1.15.tar.gz:

Publisher: release.yml on joaoh82/rust_sqlite

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

File details

Details for the file sqlrite-0.1.15-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: sqlrite-0.1.15-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlrite-0.1.15-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dfb7c272a3b5205ca550e651dc3956ed06f5b19e8f81d40355f3cfddbc362c40
MD5 5a7b1998b6e874eb57b27fb66dcbacac
BLAKE2b-256 dc8dd781c6424d1d41b17f0b917f683f10e5b2782f2343d2c00530858c64b399

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlrite-0.1.15-cp38-abi3-win_amd64.whl:

Publisher: release.yml on joaoh82/rust_sqlite

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

File details

Details for the file sqlrite-0.1.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sqlrite-0.1.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de8456f290f3ee614a114f8f30d5f1797290443c1c167885e3c32f731fe0bcb9
MD5 39011f4e5c4404f4c3b636c441b1a748
BLAKE2b-256 2350e26b990140a700d6992b8d1a4c1d0d30da56a7dcf0af63a669259bfbfff5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlrite-0.1.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on joaoh82/rust_sqlite

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

File details

Details for the file sqlrite-0.1.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for sqlrite-0.1.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 931088612a8df369d00f1ee6e2e3d8812e8301b1256c5715330ad110063f8a90
MD5 a00052c1f738c2b9a3142935329b6e9f
BLAKE2b-256 0b2d1c0280e63df51c220c2e4ffb41900116ab14f0579cde6ab6562b55b45eb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlrite-0.1.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on joaoh82/rust_sqlite

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

File details

Details for the file sqlrite-0.1.15-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sqlrite-0.1.15-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e13c031d76fb77fef1be6b7ce2cbe5c2e7b1eb8d654a9e9687a10555b4c9f21d
MD5 53edd6b8a2b0d96adcbdb7bc2f78c6b7
BLAKE2b-256 ff3627bd6bdc6dfaebf79665a9380828b7a920c99e0cfab76589118fd268451a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlrite-0.1.15-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on joaoh82/rust_sqlite

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page