Skip to main content

Python bindings for the SyncLite Rust runtime (logger + embedded consolidator)

Project description

synclite-logger (Python)

PyO3 bindings over the SyncLite Rust runtime. The Python API mirrors the Rust wrapper crate 1:1 — Connection, Statement, DuckDBConnection, DuckDBStatement, plus module-level initialize and await_sync — so Python samples read like the Rust examples in synclite-logger-rust/crates/synclite/examples/.

No DB-API adapter, no pre/post hooks, no separate user-DB connection. Python holds a Connection directly bound to the Rust type.

Build / install (editable, dev)

pip install maturin
maturin develop --release

This compiles crates/logger/bindings-python (cdylib _native) and installs the synclite package into the active environment.

Distribution wheels (per-platform)

synclite ships as platform-specific wheels — one per OS/arch — because the compiled _native extension links libduckdb natively; a single wheel cannot cover every platform. pip install synclite auto-selects the wheel matching the user's OS/arch. The full set is:

Platform Wheel tag Built by
Windows x64 win_amd64 host build (delvewheel repair)
Linux x86_64 manylinux_2_28_x86_64 Linux/WSL build (patchelf/auditwheel)
Linux aarch64 manylinux_2_28_aarch64 Linux/WSL build (patchelf/auditwheel)
macOS x86_64 / arm64 macosx_* macOS runner (delocate repair)

The repository build produces the host wheel automatically. The Linux manylinux wheels require bundling libduckdb.so + RPATH-patching via patchelf (POSIX-only, no Windows binary), so on Windows the Maven build dispatches them into WSL — see GETTING_STARTED.md → "Building Linux Python wheels". The complete cross-platform set (including macOS) is produced by CI (.github/workflows/python-wheels.yml).

Quickstart

import synclite as sl

sl.initialize(
    device_type="SQLITE",
    device_name="sampledevice",
    db_path="myapp.db",
    destination=sl.DestinationOptions(
        dst_type="POSTGRES",
        dst_connection_string="postgresql://user:pw@localhost:5432/syncdb",
        dst_database="syncdb",
        dst_schema="public",
    ),
)

conn = sl.Connection.open("myapp.db")
conn.execute("CREATE TABLE t(id INTEGER PRIMARY KEY, name TEXT)")

stmt = conn.prepare("INSERT INTO t(id, name) VALUES(?, ?)")
stmt.execute([1, "Alice"])
stmt.add_batch([2, "Bob"])
stmt.add_batch([3, "Carol"])
stmt.execute_batch()

for row in conn.query("SELECT id, name FROM t ORDER BY id"):
    print(row)

conn.commit()
conn.flush()
sl.await_sync("myapp.db", 30.0)
conn.close()

For DuckDB, swap Connection for DuckDBConnection and device_type="DUCKDB". For STORE / STREAMING devices, write a config file with device-type=SQLITE_STORE or STREAMING and open with Connection.open_with_config(path).

See synclite-code-samples/synclite-logger/python/ for runnable samples — each one is a 1:1 mirror of the corresponding Rust example.

Parameter / row conversion

Python Rust Value
None Value::Null
bool Value::Int(0/1)
int Value::Int
float Value::Real
str Value::Text
bytes Value::Blob

query(...) returns list[tuple] using the same mapping in reverse.

Pass parameters as a list or tuple; pass nothing (or None) for parameterless statements.

API surface

  • initialize(device_type, device_name, db_path, destination=None, config_path=None)
  • await_sync(db_path, timeout_seconds)
  • DestinationOptions(dst_type, dst_connection_string, dst_database=None, dst_schema=None, dst_sync_mode="CONSOLIDATION")
  • Connection.open(path) / open_with_config(path) / initialize(path) / initialize_with_config(path)
  • Connection.execute(sql, params=None) -> int
  • Connection.query(sql, params=None) -> list[tuple]
  • Connection.prepare(sql) -> Statement
  • Connection.{commit,rollback,flush,close,set_auto_commit,get_auto_commit}
  • Statement.execute(params=None) -> int
  • Statement.query(params=None) -> list[tuple]
  • Statement.{add_batch,clear_batch,execute_batch}
  • DuckDBConnection / DuckDBStatement: identical shape.

device_type, dst_type, dst_sync_mode are accepted as case-insensitive strings:

  • device_type: "SQLITE", "SQLITE_STORE", "STREAMING", "DUCKDB", "DUCKDB_STORE"
  • dst_type: "SQLITE", "DUCKDB", "POSTGRES"
  • dst_sync_mode: "CONSOLIDATION", "REPLICATION"

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.

synclite-1.0.0-cp38-abi3-win_amd64.whl (17.2 MB view details)

Uploaded CPython 3.8+Windows x86-64

synclite-1.0.0-cp38-abi3-manylinux_2_28_x86_64.whl (28.4 MB view details)

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

synclite-1.0.0-cp38-abi3-manylinux_2_28_aarch64.whl (25.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

File details

Details for the file synclite-1.0.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: synclite-1.0.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 17.2 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for synclite-1.0.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f8b7e71acf953a0b8a65e089c5a272293ed4638bc4f2732c4d4acaad924d819a
MD5 043f7ca58269cb04d9479e6b3fda8daf
BLAKE2b-256 bb3d68fe183613cc2ad3291b4568e30031eb5814d4fa39e3580611790b9e25fb

See more details on using hashes here.

File details

Details for the file synclite-1.0.0-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for synclite-1.0.0-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9537938db33c0190ab97b7d760cadebe904777f05744d5b3b7c834746564618
MD5 da61d38fb0be2f44bb6c465ba68a5b91
BLAKE2b-256 fad5366093f19d437a015e3a04b411eb601f219e7dca21e6aca87a94b3db03b6

See more details on using hashes here.

File details

Details for the file synclite-1.0.0-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclite-1.0.0-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 82bb814753cba54463ec415ab27ad4223503ef603da3f6c95c5a1110ad9d81ab
MD5 6e6d28e9bcf9b448aac1d1670d5aab3a
BLAKE2b-256 19c91ea1b3b40b2c13c5471a0ad3a0d90c6e90fd3563c51a7e13ecfc497266b8

See more details on using hashes here.

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