SlateDB Python Binding
bindings/python contains the official UniFFI-based Python package for SlateDB.
Requirements
- Python 3.10 or newer
Install
pip install slatedb
API Model
ObjectStore.resolve(...)opens an object store from a URL such asmemory:///DbBuilderopens a writable database andDbReaderBuilderopens a read-only reader- most database operations are
asyncand should be used withasyncio WriteBatchis mutated synchronously and then consumed bydb.write(...)db.shutdown()andreader.shutdown()explicitly close native resources
Quick Start
import asyncio
from slatedb.uniffi import (
DbBuilder,
IsolationLevel,
KeyRange,
ObjectStore,
WriteBatch,
)
async def main() -> None:
store = ObjectStore.resolve("memory:///")
builder = DbBuilder("demo-db", store)
db = await builder.build()
try:
await db.put(b"user:1", b"Alice")
value = await db.get(b"user:1")
assert value == b"Alice"
batch = WriteBatch()
batch.put(b"user:2", b"Bob")
batch.put(b"user:3", b"Carol")
await db.write(batch)
scan = await db.scan_prefix(
b"user:",
KeyRange(
start=None,
start_inclusive=False,
end=None,
end_inclusive=False,
),
)
while (row := await scan.next()) is not None:
print(row.key, row.value)
tx = await db.begin(IsolationLevel.SERIALIZABLE_SNAPSHOT)
await tx.put(b"user:4", b"Dora")
await tx.commit()
finally:
await db.shutdown()
asyncio.run(main())
Metrics
The Python binding exposes both custom metrics callbacks and the built-in
DefaultMetricsRecorder:
DbBuilder.with_metrics_recorder(...)DbReaderBuilder.with_metrics_recorder(...)DefaultMetricsRecorder.snapshot()DefaultMetricsRecorder.metrics_by_name(...)DefaultMetricsRecorder.metric_by_name_and_labels(...)
Example:
from slatedb.uniffi import DbBuilder, DefaultMetricsRecorder, ObjectStore
store = ObjectStore.resolve("memory:///")
recorder = DefaultMetricsRecorder()
builder = DbBuilder("metrics-demo", store)
builder.with_metrics_recorder(recorder)
db = await builder.build()
try:
await db.put(b"hello", b"world")
metric = recorder.metric_by_name_and_labels("slatedb.db.write_ops", [])
if metric is not None and metric.value.is_counter():
print(metric.value[0])
finally:
await db.shutdown()
Runtime Notes
Writable databases and readers enter a dedicated multi-threaded Tokio runtime while opening so SlateDB's long-lived background tasks capture a multi-threaded Tokio handle. Foreground binding calls are still awaited through the normal Python async API. By default, the runtime uses the host's available parallelism. Set SLATEDB_UNIFFI_RUNTIME_THREADS to a positive integer before the first DbBuilder.build() or DbReaderBuilder.build() call to override the worker thread count for the lifetime of the process.
Local Development
This package reuses the shared Rust UniFFI crate at ../uniffi/Cargo.toml. The generated Python module under slatedb/uniffi/_slatedb_uniffi/ is build output and should not be edited by hand.
Editable Build
From the repository root:
cd bindings/python
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install maturin "uniffi-bindgen==0.31.0" ruff
maturin develop
ruff check .
python -c "import slatedb; import slatedb.uniffi; from slatedb.uniffi import *"
Run Tests
From bindings/python after building the extension with test extras:
maturin develop --extras test
pytest
Build Release Artifacts
From bindings/python:
maturin build
maturin sdist
Editable builds generate slatedb/uniffi/_slatedb_uniffi/ in-tree. If you switch from maturin develop to maturin build in the same checkout, remove that generated directory first or run the artifact build from a fresh checkout.
License
SlateDB is licensed under the Apache License, Version 2.0.
Metadata
Release files for slatedb 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| slatedb-0.17.0.tar.gz | 1.1 MB | Details |
Built distributions (wheels)
Total release size: 123.7 MB
Release files / slatedb-0.17.0.tar.gz
| Download URL | slatedb-0.17.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c057a186b3a2cd733a65f173e6c1d119c5ca5e5ca837d0294e6f9c26f798b54f
|
|
BLAKE2b-256 checksum How to use checksums |
d812879cf5768af581d37eee6db898c4a7ec7a7cb3b888252e2660d5a4e4d131
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-win_amd64.whl
| Download URL | slatedb-0.17.0-py3-none-win_amd64.whl |
|---|---|
| Size | 9.3 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e8d46942fe1b8627d7918db0b25e06ed30242a23b704781b06c43955d9609254
|
|
BLAKE2b-256 checksum How to use checksums |
5cc1d0e9d68383cb062ddfb53acf3b0b08b350a09eafee0f6dd7f09e78aaff4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-win32.whl
| Download URL | slatedb-0.17.0-py3-none-win32.whl |
|---|---|
| Size | 8.2 MB |
| Tags | Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
6e56e40b11642702c96c17ab1bb288d902a03bab7d6641136bd944a5a64ffa12
|
|
BLAKE2b-256 checksum How to use checksums |
247cf623e3623897b1c6618736bc7c2650e4126886fda8ce50d2693d6abd7971
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | slatedb-0.17.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 10.9 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
92a1ef44ae0f9670d41395be00de6b82e2450bd555fcc6ea8ac6c279deea2539
|
|
BLAKE2b-256 checksum How to use checksums |
34c0df6a77a9155122f664fb5290fff278ac30af46d2b9997d5236f44a3f3662
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-musllinux_1_2_i686.whl
| Download URL | slatedb-0.17.0-py3-none-musllinux_1_2_i686.whl |
|---|---|
| Size | 10.8 MB |
| Tags | Linux musl 1.2+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
5cf4f7540f5961c1233921cdf42caf9e6592481215876529ae8838d4220f3412
|
|
BLAKE2b-256 checksum How to use checksums |
8a30236a6d5e9fe57798902676a4cfbae674dd215d5c7df2e957a3d3a0603d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-musllinux_1_2_armv7l.whl
| Download URL | slatedb-0.17.0-py3-none-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 10.1 MB |
| Tags | Linux musl 1.2+ ARMv7l Python 3 |
|
SHA-256 checksum How to use checksums |
9a40d2eea92d3f9d3b9cc4c5aa28c1e7c28579f843dabe4dd8657b8880ac6161
|
|
BLAKE2b-256 checksum How to use checksums |
fd0197479c20398ca16bd2339decb522e8895fa848e601f42dec5a433b147e12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | slatedb-0.17.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 10.7 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
5b088e23c4371f650d42df9944290b73ec71754d6defc7f7964c95569ad131a9
|
|
BLAKE2b-256 checksum How to use checksums |
b0f6960743c9c1bfc259962b3d60a0fcd85dcd0ba94fc274a8b689fd6c1bb7ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | slatedb-0.17.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 10.6 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
79252f859331010ef9f6532b1a244db8dc6e29367236d022e78e6fcd12d3560a
|
|
BLAKE2b-256 checksum How to use checksums |
75fb7a9189c2d9bb061a54cb3b5cd17021f2ecbe9c0e86ce1a30582359e5e458
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | slatedb-0.17.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 11.5 MB |
| Tags | Linux glibc 2.17+ PowerPC 64-le Python 3 |
|
SHA-256 checksum How to use checksums |
ab92d54582f4be240867ada3df3c494556950a1b6fa7f3879cd6b7a205be038a
|
|
BLAKE2b-256 checksum How to use checksums |
b65c32679f50df8b32a2db358dd1b37ad8c550c717c77fb13bf677fb55306a6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | slatedb-0.17.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 11.1 MB |
| Tags | Linux glibc 2.17+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
9ea756ca3c0026c3c5af98177ef0216055da03f9a3498fbdf8855fe0c26bb5fa
|
|
BLAKE2b-256 checksum How to use checksums |
ac216206b1cc9e720d7c8332d5cbc9aa72f43517bda62d065c73fda2cfe8ec41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | slatedb-0.17.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 9.9 MB |
| Tags | Linux glibc 2.17+ ARMv7l Python 3 |
|
SHA-256 checksum How to use checksums |
c9331beb3d20088f90668ef729329734c0e8d4ee029adab2de7b00174d87b7fc
|
|
BLAKE2b-256 checksum How to use checksums |
4b5b9a697f6cdefbe2bfaf4e70516c008ba47c4b353f6b9d242ee36aa10a5aeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | slatedb-0.17.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 10.5 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
63366b5a895e4b3cd47295fd4ce7eb2a2125804b34b548c18b3a74eded34462c
|
|
BLAKE2b-256 checksum How to use checksums |
082f4ca146c0d933ac0292b20c4168e0f6176e2c1d8c8d4b63d59ba31ae8ed05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / slatedb-0.17.0-py3-none-macosx_11_0_arm64.whl
| Download URL | slatedb-0.17.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 9.1 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d3159602b659447ebf4406258e29395c99832b590fcf75c32a6426d20de8d81f
|
|
BLAKE2b-256 checksum How to use checksums |
07cab2689cb1f681dffabfd5168ca4c1decb176d7d141fbd724a7f31fb976625
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|