A cloud native embedded storage engine built on object storage.
Project description
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,
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:")
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()
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slatedb-0.13.0.tar.gz.
File metadata
- Download URL: slatedb-0.13.0.tar.gz
- Upload date:
- Size: 798.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7c89840117c43bc7fd091aa0bd86f8ed21febb0e51c5deaac8bdf907d588217
|
|
| MD5 |
f1df4168da1d6176a33ada715ec37ce4
|
|
| BLAKE2b-256 |
7aedc7ecbea3301d1518e97e69f6a29529497bfe70d1fb5bbee06a52470c89f9
|
File details
Details for the file slatedb-0.13.0-py3-none-win_amd64.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-win_amd64.whl
- Upload date:
- Size: 7.3 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5628b50ccd37a591ca08e788c811d8441544dcb22dca7a3c975005889c97b5cd
|
|
| MD5 |
e56d7bd58d7b57be38f9ef933f2d624c
|
|
| BLAKE2b-256 |
7289d922602f8fc0912452d4ff2147397bb148439d34098a41fe5376fd8d5520
|
File details
Details for the file slatedb-0.13.0-py3-none-win32.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-win32.whl
- Upload date:
- Size: 6.4 MB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8720f4da36096f882df69cb6b4e2ecd970f2e43442446dbaeb7e140dee7b21bc
|
|
| MD5 |
df0df001d4af7607bb6cf874d9269393
|
|
| BLAKE2b-256 |
4b454c5cab9fb45676451cb9eed2ff3f3fd2e261e3c135c3b0b51f5df2bebb44
|
File details
Details for the file slatedb-0.13.0-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 8.7 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2dedb8ae04f1d3b34297d7d309bface576128451a4fe31ca9f638c1f25aed31
|
|
| MD5 |
ff1b4b5f01ce1bcf526a5a4f1e82250c
|
|
| BLAKE2b-256 |
9d912b90b2b50002ac11e4c5da2b44ecc5aa8ee1f60efa0a1fa7b1a91309e5b6
|
File details
Details for the file slatedb-0.13.0-py3-none-musllinux_1_2_i686.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-musllinux_1_2_i686.whl
- Upload date:
- Size: 8.8 MB
- Tags: Python 3, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8154aaf3ce1a309dd09674679fb8bb46315dacce83fc9699a46ec8b8128e8e0d
|
|
| MD5 |
1222c6a0fc14234955dd04de07e97252
|
|
| BLAKE2b-256 |
3476dc427c65c013388a74d10ac314be21e95680f693686aa5c110c2d027df60
|
File details
Details for the file slatedb-0.13.0-py3-none-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 8.2 MB
- Tags: Python 3, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7e7f07359c5a728002a330470207daa68932c6536a13905f531d4b968ea1a2c
|
|
| MD5 |
ac51563aa0b2fd5eb369b409b33de235
|
|
| BLAKE2b-256 |
b10c1797c24eebfcc7936b4220e5c55d45ce77ab3ecd57accda6fe524c0f3d74
|
File details
Details for the file slatedb-0.13.0-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 8.5 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fbfb5bf546450c9b4a656a5597853b431713c99575459998bb736d300327ca1
|
|
| MD5 |
4f605c3c75ecb77b93e3e3f04fdea97c
|
|
| BLAKE2b-256 |
f004979a113f0757ff923a3206ec023b7663d15d27387de3b73ed5680717ccfd
|
File details
Details for the file slatedb-0.13.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 8.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c5299c1e16f44dcf0a82ddfc1a8588b403bc3f7f7c60307e06320dbe1ac7c0
|
|
| MD5 |
b4ef6ad687a1fa2246c135de7bae2f15
|
|
| BLAKE2b-256 |
aca898a3d9975349aebbf8d88f73436b2136e9438f6f31bd6f149b993e02f1d3
|
File details
Details for the file slatedb-0.13.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 8.0 MB
- Tags: Python 3, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d645c397fcb274683790d422f2f0c700ce90eb5a00bfcbdb30031c453d9d08cf
|
|
| MD5 |
2b43967033ebf3c415c05e16e4d72bf4
|
|
| BLAKE2b-256 |
38efca132779dfeacbb123596bb93a5a127d728d8555cb4f8e30488b6254d3b7
|
File details
Details for the file slatedb-0.13.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 9.6 MB
- Tags: Python 3, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34cdddb198ec6386e6fd32fc7880dfb872a99552a0566e88e60605b024dac359
|
|
| MD5 |
d0145f4c6ae2efa976e659509008da61
|
|
| BLAKE2b-256 |
29b25b7be118912f705b5efb725b8a49f7f9205adae919e8c78e5df386d2d774
|
File details
Details for the file slatedb-0.13.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 9.0 MB
- Tags: Python 3, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a76faa79b40d3ea3d59aa599996935d4d40987be1c7515cd5ed82c40a197637e
|
|
| MD5 |
32a20d5208371ced4ea53806d04c7404
|
|
| BLAKE2b-256 |
a88fb4c700d720f44db8ca500a2f103510373e0e34f48aa189c1f31565223c99
|
File details
Details for the file slatedb-0.13.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 8.0 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f28e1a6c074c3ef0465f421136952479cced096ee50ec9a90cb449d0303bcf7
|
|
| MD5 |
5002232247d78b72414ea7b3a52eda94
|
|
| BLAKE2b-256 |
3d663b5bafe84d8a5f6e211b91f8ca310ca921c182dd57206a1d78d85182d46e
|
File details
Details for the file slatedb-0.13.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 8.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b55e4ccbaafa0a8e23cd13eff3075f8e94102e4e49c09b84a71bb376ca6dc96
|
|
| MD5 |
464d338eb8b970360de26cd5f503d80b
|
|
| BLAKE2b-256 |
53ff9f1c8e00b1dd713b44480699a493ea47362c776f96f3402b284d74dba4e1
|
File details
Details for the file slatedb-0.13.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: slatedb-0.13.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 7.5 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e3b59344214952f6cda7cfe08bcab837a4c9bef475a13414f5d817608fdf26d
|
|
| MD5 |
50444c7b530616031acb2ee9cadf6a8b
|
|
| BLAKE2b-256 |
b47d0f2ca01abad519eba7adf55cf7f5928d46dd81a4c7fa59df22e54c208225
|