Skip to main content

Python (DB-API 2.0) binding for SQLXtraLite — a from-scratch SQL engine in Rust

Project description

SQLXtraLite — Python binding (PyO3, DB-API 2.0)

A native CPython extension built with PyO3 that calls the Rust engine directly (no C-ABI round-trip) and exposes a small DB-API 2.0 surface. Values come back as native Python types (int, float, str, bytes, None).

There's also a zero-dependency ctypes binding in ../python/ — no build tools, but it returns string values. This PyO3 binding is the idiomatic, pip-installable one. The engine crate itself stays dependency-free; PyO3 lives only here.

Build & install

# from this directory (bindings/pyo3)
pip install maturin

maturin develop --release      # build + install into the current venv
# or build a redistributable wheel:
maturin build --release        # -> target/wheels/sqlxtralite-*.whl
pip install target/wheels/sqlxtralite-*.whl

A plain cargo build --release also links a loadable module here (via .cargo/config.toml); rename target/release/libsqlxtralite.dylibsqlxtralite.so (.so on Linux) on your PYTHONPATH to import it without maturin.

Use

import sqlxtralite

con = sqlxtralite.connect("shop.db")
cur = con.cursor()
cur.execute("CREATE TABLE items (id INTEGER PRIMARY KEY, name TEXT, price REAL)")

cur.executemany("INSERT INTO items VALUES (?, ?, ?)",
                [(1, "basil", 2.95), (2, "mint", None)])

cur.execute("SELECT * FROM items WHERE price > ?", (1.0,))
print(cur.description)     # [('id', None, …), ('name', …), ('price', …)]
print(cur.fetchall())      # [(1, 'basil', 2.95)]   ← native int / str / float
print(cur.lastrowid, cur.rowcount)
con.close()

API (DB-API 2.0 subset)

Module: connect(path), apilevel = "2.0", threadsafety = 1, paramstyle = "qmark", Error.

Object Methods / attrs
Connection cursor(), execute(sql, params=None), commit(), rollback(), close(), context manager
Cursor execute(sql, params=None), executemany(sql, seq), fetchone(), fetchmany(size=1), fetchall(), description, rowcount, lastrowid, close()

Parameters use qmark style (?), positional; None→NULL, int/float/str/ bytes bind directly. Prepared statements are used automatically when you pass params (and for executemany), giving the engine's fast bind path.

Run the test

maturin develop --release
python3 test_dbapi.py
# OK — PyO3 DB-API binding works

Notes

  • Connection/Cursor are unsendable — use one connection per thread (the engine is single-writer; the GIL serializes calls anyway).
  • SQLXtraLite auto-commits each statement, so commit()/rollback() are no-ops provided for DB-API shape; use explicit BEGIN/COMMIT SQL for multi-statement transactions.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

sqlxtralite-0.1.0-cp38-abi3-win_amd64.whl (748.6 kB view details)

Uploaded CPython 3.8+Windows x86-64

sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (912.1 kB view details)

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

sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (866.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

sqlxtralite-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (812.1 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file sqlxtralite-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: sqlxtralite-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 748.6 kB
  • 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 sqlxtralite-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7e621acd9c129bd403c5f97ff256145092db243cd9e86c5f620122b838c5bcbe
MD5 89278fd3deaa07839d4568c5b42d50ac
BLAKE2b-256 4769e3c163b7eda078396592c939df8e2b1d028834a62b7f90b7382ce57db7a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlxtralite-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: wheels.yml on parisxmas/SQLXtraLite

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

File details

Details for the file sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 279d16459b7fbd33a39e2b094e56e09649ca3326de232c9218f91531e49f5aaa
MD5 61114d71c2768a5ed616d250e4708093
BLAKE2b-256 67539d3a66c21ac5d24eda4e0fc82314d6b851a9c6fb9ce303d51c6844fcf713

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on parisxmas/SQLXtraLite

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

File details

Details for the file sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1d008718f34d69b7221d4a7c84b8c7e20f7753bc369058b5f31d7008c0c700bb
MD5 a0a8b39b681ed250d13f8868203d1879
BLAKE2b-256 bb36b2d1918598deffdb8a916c94049b0632cbf5f79c95f3675d9654653711c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlxtralite-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on parisxmas/SQLXtraLite

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

File details

Details for the file sqlxtralite-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sqlxtralite-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d41ccc4cc126ee601e49abae5f4fde20115dbb2b716aff0ef5079c9b2e3280b
MD5 1231ccafcbd54b4b4c64046047c1220d
BLAKE2b-256 e309248fec9b97e13f93c005d27887b76f5ac8dffbde2281bcf72085a7942bad

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlxtralite-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on parisxmas/SQLXtraLite

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