Skip to main content

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 as memory:///
  • DbBuilder opens a writable database and DbReaderBuilder opens a read-only reader
  • most database operations are async and should be used with asyncio
  • WriteBatch is mutated synchronously and then consumed by db.write(...)
  • db.shutdown() and reader.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.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slatedb 0.18.0
File Size Uploaded Provenance Actions
slatedb-0.18.0.tar.gz 1.3 MB Without provenance Details for slatedb-0.18.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for slatedb 0.18.0
File Actions
slatedb-0.18.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for slatedb-0.18.0-py3-none-win_amd64.whl
slatedb-0.18.0-py3-none-win32.whl Python 3 none Windows x86-32 Details for slatedb-0.18.0-py3-none-win32.whl
slatedb-0.18.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for slatedb-0.18.0-py3-none-musllinux_1_2_x86_64.whl
slatedb-0.18.0-py3-none-musllinux_1_2_i686.whl Python 3 none Linux musl 1.2+ x86-32 Details for slatedb-0.18.0-py3-none-musllinux_1_2_i686.whl
slatedb-0.18.0-py3-none-musllinux_1_2_armv7l.whl Python 3 none Linux musl 1.2+ ARMv7l Details for slatedb-0.18.0-py3-none-musllinux_1_2_armv7l.whl
slatedb-0.18.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for slatedb-0.18.0-py3-none-musllinux_1_2_aarch64.whl
slatedb-0.18.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for slatedb-0.18.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
slatedb-0.18.0-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl Python 3 none Linux glibc 2.17+ PowerPC 64-le Details for slatedb-0.18.0-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
slatedb-0.18.0-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl Python 3 none Linux glibc 2.17+ x86-32 Details for slatedb-0.18.0-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl
slatedb-0.18.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details for slatedb-0.18.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl
slatedb-0.18.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for slatedb-0.18.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
slatedb-0.18.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for slatedb-0.18.0-py3-none-macosx_11_0_arm64.whl

Total release size: 128.2 MB

Release files / slatedb-0.18.0.tar.gz

Download URL slatedb-0.18.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
a50131e146422e217486ee34254ab8b3aea7f36293b9be8ed9b16c9b4fdb10e0
BLAKE2b-256 checksum
How to use checksums
a6f43772ef9b6e86abef7fbe7d58c1e7d8015f28aadbc17b4b8b3f00ea519c73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-win_amd64.whl

Download URL slatedb-0.18.0-py3-none-win_amd64.whl
Size 9.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
c5aa8ecee22d5cc5a3f002b9e3cda571b8d2b3ea6a8ad4154aa6246ca1fc7152
BLAKE2b-256 checksum
How to use checksums
91c801eabbc1b69b7e1c67a51b92ed0ed187d38ea719c05a5baac7719c187766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-win32.whl

Download URL slatedb-0.18.0-py3-none-win32.whl
Size 8.5 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
58f4572e828b13cfb8d24af2aeb91b62d79fe5a7bb9878e1491aa079c08a9d39
BLAKE2b-256 checksum
How to use checksums
cd6a658e025113a52347a53017306c31d32eed726528641745bdd33cc12cdb36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-musllinux_1_2_x86_64.whl

Download URL slatedb-0.18.0-py3-none-musllinux_1_2_x86_64.whl
Size 11.3 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
5cc982c97a83a997a0c5802d21005e527a191626e2613c9382c1ea55386f4f21
BLAKE2b-256 checksum
How to use checksums
ab42338a30ca4e929c90fcdcc3548bfde2c3f2aa4e7763adffeb5fce704db98d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-musllinux_1_2_i686.whl

Download URL slatedb-0.18.0-py3-none-musllinux_1_2_i686.whl
Size 11.1 MB
Tags Linux musl 1.2+ x86-32 Python 3
SHA-256 checksum
How to use checksums
4ce136359860f06f5fff2119ace6dea5aff365e63c176c229d479feda0516fe5
BLAKE2b-256 checksum
How to use checksums
bdae1ea3c23febf3e40b8625795aa3c8e3cb519428305bf5752c9e41ff5dcc49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-musllinux_1_2_armv7l.whl

Download URL slatedb-0.18.0-py3-none-musllinux_1_2_armv7l.whl
Size 10.4 MB
Tags Linux musl 1.2+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
5f6853bdf3d21a4bac37b44f7b771e4dfc6bf37674fa2638f36ed040e7047996
BLAKE2b-256 checksum
How to use checksums
9531eb2a292d13d17eabe88612e0c512bb733f975d1a4a480fac594e17bb88c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-musllinux_1_2_aarch64.whl

Download URL slatedb-0.18.0-py3-none-musllinux_1_2_aarch64.whl
Size 11.1 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
cce49daac25c0ba5886beb890340b6f6f765fcffc4cbb12a489e019516e70be2
BLAKE2b-256 checksum
How to use checksums
b59d86843d13278fbfbad1ee09c86890da19f83a7625b473df0f9249474ab732
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL slatedb-0.18.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 10.9 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
fdcd64b03c08d6092be46861212000d94dc55f4bfd5d7ff2b3d3ba031884ad23
BLAKE2b-256 checksum
How to use checksums
306d3cbb7cb506f7baff81e99b523f02e9faaa392ac961acc69450f0286531b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl

Download URL slatedb-0.18.0-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
Size 12.0 MB
Tags Linux glibc 2.17+ PowerPC 64-le Python 3
SHA-256 checksum
How to use checksums
4c2d1c94f1a94d485358c80c74384a1b59a487ed292aef17f29353c91a30b9cb
BLAKE2b-256 checksum
How to use checksums
a4e093f221507ed838e00be30abcb83372ec326a2b864efb3b3ab9d58a4f3ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl

Download URL slatedb-0.18.0-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl
Size 11.5 MB
Tags Linux glibc 2.17+ x86-32 Python 3
SHA-256 checksum
How to use checksums
10c1b0e8cc9e791e84be3043fa64104f42cbb97dd16c82cd4f819be66260a3f4
BLAKE2b-256 checksum
How to use checksums
59138102cdfcb91d188b6b20b958824b26012cb06d6db30f93ae85e2b600d1b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl

Download URL slatedb-0.18.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl
Size 10.2 MB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
102c49034c7ad5d467d2873db701bb080d378b8e5b574d9a242777098df7ff95
BLAKE2b-256 checksum
How to use checksums
7f7529fb8f02cd7ddfc1f89767d0b0d9472f7c468225780e94ceb2379d83fcf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL slatedb-0.18.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 10.9 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
84e4ef41534b9129a3e3be72f4305ca3c9c78299d74bd8ac990f605a312e2073
BLAKE2b-256 checksum
How to use checksums
07ffb1f62a46e1489a546102497bffc1ae04173736bd5a65b2ee28fdd069cb2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / slatedb-0.18.0-py3-none-macosx_11_0_arm64.whl

Download URL slatedb-0.18.0-py3-none-macosx_11_0_arm64.whl
Size 9.4 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ab982fcc0ca6ba8d87c150df07bbeca151c117dd3b8ee295843ed852c2e29afc
BLAKE2b-256 checksum
How to use checksums
a2d51a9510eb6286a99b1f10e36e3604abed8df6c9202adea8bdc704cf65ad2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for slatedb 0.18.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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