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.1

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.1
File Size Uploaded Provenance Actions
slatedb-0.18.1.tar.gz 1.3 MB Without provenance Details for slatedb-0.18.1.tar.gz

Built distributions (wheels)

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

Total release size: 128.2 MB

Release files / slatedb-0.18.1.tar.gz

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

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

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

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

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

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

Download URL slatedb-0.18.1-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
212128730ae19679f5cb501345a7e5f617b1d8cf1e99055f375f5a4516596d4e
BLAKE2b-256 checksum
How to use checksums
22e3a302adc68a4b6ec1e1e1f1e8969c7a5870590a4447122c3ab00a34551e6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
73ae034bce7fbaad72ba0479537a52786b7cd7fa31c52cc7308387de44c741c1
BLAKE2b-256 checksum
How to use checksums
0ce21d3435b1efd97adc6dbcc347694a166af4b0ec14badbb821f6cee28aff3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
f33d40c079174965965af9901044f546637fa92151ad559b5fe428c7f47943bc
BLAKE2b-256 checksum
How to use checksums
67ec95323596f0daaa4e8fe83b729f23e5c287e48a1c47027d08adf41d21abbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
a282438f217ff5b6a47e6c6f141181a6f4f99feea7965df5f46082318317f510
BLAKE2b-256 checksum
How to use checksums
261ed79a7c907afa3384cb7f25936d976fd777b4759fb62fe9019a669597d9ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
ba270d5e50006b8f1bfae4f88e2c8595e1eaee8e5056b5e6e1d011ac5140b013
BLAKE2b-256 checksum
How to use checksums
1fc619d21fce8a7490316c71a12237a2023f71e7728931f1fe27ffe72888b44d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
521a81d2a5272965ac005ba5e6502477e671d5e5e5b1ece53e66d719de19c021
BLAKE2b-256 checksum
How to use checksums
21192c6858da9f372130ffc9ab58de49867b400b5a91da4cb07a6f50d0b1bfdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
c8a2483a13e42bca5255eb90e4213ad47c9660c542d5cef85768c73cb85eab24
BLAKE2b-256 checksum
How to use checksums
97999f9b36b8dea224393c6e2685e4585f60ffcd38099bffc5fd9092669a245c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
276795e39b4254cab09e3e5e1820a59f4ac3a9ca3f6409dc78b51340f8d0e0a2
BLAKE2b-256 checksum
How to use checksums
06a7b95ba7d31c880f54775e1b8bea7c610f1e1031e4a6de56f3ba9a181a1401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
b028fee550e678d34a6b4fcde82521b7a779673d61bdceb1877aea06cb0f9a63
BLAKE2b-256 checksum
How to use checksums
9fb3937b39035c1297dc5e45d2cab79be3d100725b5cce8fc94ff0e8823bcccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

Download URL slatedb-0.18.1-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
9363d51b23127e774ea2743b2d57f55b78abced76d5e2df83fd873fbe9dd21ef
BLAKE2b-256 checksum
How to use checksums
70bad0492a4c44266d822116eb1895d414c47fcfa7252c5445aee4ec306be1cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for slatedb 0.18.1

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