Skip to main content

A Python binding for SlateDB

Project description

SlateDB

PyPI Python Versions GitHub License slatedb.io Discord

WARNING

This is alpha software and is not yet ready for production use. Missing features:

  • Only uses in-memory object storage
  • No range query
  • No checkpoints
  • No builders
  • ... and more

Please see SlateDB's Python Github issues to contribute.

Introduction

SlateDB is an embedded storage engine built as a log-structured merge-tree. Unlike traditional LSM-tree storage engines, SlateDB writes data to object storage (S3, GCS, ABS, MinIO, Tigris, and so on). Leveraging object storage allows SlateDB to provide bottomless storage capacity, high durability, and easy replication. The trade-off is that object storage has a higher latency and higher API cost than local disk.

To mitigate high write API costs (PUTs), SlateDB batches writes. Rather than writing every put() call to object storage, MemTables are flushed periodically to object storage as a string-sorted table (SST). The flush interval is configurable.

put() returns a Future that resolves when the data is durably persisted. Clients that prefer lower latency at the cost of durability can instead use put_with_options with await_durable set to false.

To mitigate read latency and read API costs (GETs), SlateDB will use standard LSM-tree caching techniques: in-memory block caches, compression, bloom filters, and local SST disk caches.

Checkout slatedb.io to learn more.

Installation

pip install slatedb

Requirements

  • Python 3.10 or higher

Usage

Basic Operations

from slatedb import SlateDB

# Create or open a database
db = SlateDB("/path/to/your/database")

# Put a key-value pair
db.put(b"hello", b"world")

# Retrieve a value
value = db.get(b"hello")  # Returns b"world"

# Delete a key-value pair
db.delete(b"hello")

# Always close when done
db.close()

Asynchronous API

SlateDB also provides async methods for use with asyncio:

import asyncio
from slatedb import SlateDB

async def main():
    db = SlateDB("/path/to/your/database")

    # Async operations
    await db.put_async(b"hello", b"async world")
    value = await db.get_async(b"hello")
    await db.delete_async(b"hello")

    # Don't forget to close
    db.close()

# Run the async example
asyncio.run(main())

Error Handling

Most methods raise ValueError for errors like empty keys or database operation failures:

try:
    db.put(b"", b"This will fail")
except ValueError as e:
    print(f"Error: {e}")

Documentation

There's no Python documentation for SlateDB. Checkout slatedb.io for architecture and read the Python binding source code for API documentation.

License

SlateDB is licensed under the Apache License, Version 2.0.

Foundation

SlateDB is a member of the Commonhaus Foundation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slatedb-0.6.1.tar.gz (271.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slatedb-0.6.1-cp313-cp313-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file slatedb-0.6.1.tar.gz.

File metadata

  • Download URL: slatedb-0.6.1.tar.gz
  • Upload date:
  • Size: 271.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for slatedb-0.6.1.tar.gz
Algorithm Hash digest
SHA256 e70758e2ca56dbcdb1e46179ffd0e4b78b32177ca49a4e94f15aef9f8a7dc3a8
MD5 d381218c4b756a50a432a2d2488f0ef0
BLAKE2b-256 3fb13c6372474d8d1c4ed4d92c911ccfb4fa00ecb7f212d2c931286d37bdc68f

See more details on using hashes here.

File details

Details for the file slatedb-0.6.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slatedb-0.6.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a9df69496701a6921b47b2be9bc818bfb122cc479fccb0265401626b97c8869
MD5 6f576a60a53ddea91f57599151717856
BLAKE2b-256 a2bba849d63509df76f1879f3c7f37575af1345de2d80854e0e2d0b5ec6d47d0

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