Skip to main content

dbx-py

PyPI License Guide

Python bindings for the DBX high-performance embedded database.

Installation

From Source

cd bindings/python
pip install -e .

This will automatically build the Rust FFI library and install the Python package.

Quick Start

from dbx_py import Database

# Open an in-memory database
db = Database.open_in_memory()

# Or open a file-based database
# db = Database("my_database.db")

# Insert data
db.insert("users", b"user:1", b"Alice")
db.insert("users", b"user:2", b"Bob")

# Get data
value = db.get("users", b"user:1")
print(value.decode('utf-8'))  # Output: Alice

# Count rows
count = db.count("users")
print(f"Total users: {count}")  # Output: Total users: 2

# Delete data
db.delete("users", b"user:2")

# Flush to disk
db.flush()

# Close database
db.close()

Context Manager Support

with Database("my_database.db") as db:
    db.insert("users", b"user:1", b"Alice")
    value = db.get("users", b"user:1")
    print(value.decode('utf-8'))
# Database is automatically closed

API Reference

Database(path: str)

Open a database at the specified path.

Parameters:

  • path (str): Path to the database file

Returns:

  • Database: Database instance

Database.open_in_memory() -> Database

Open an in-memory database.

Returns:

  • Database: Database instance

insert(table: str, key: bytes, value: bytes) -> None

Insert a key-value pair into a table.

Parameters:

  • table (str): Table name
  • key (bytes): Key data
  • value (bytes): Value data

Raises:

  • RuntimeError: If insertion fails

get(table: str, key: bytes) -> Optional[bytes]

Get a value by key from a table.

Parameters:

  • table (str): Table name
  • key (bytes): Key data

Returns:

  • bytes or None: Value data if found, None otherwise

Raises:

  • RuntimeError: If operation fails

delete(table: str, key: bytes) -> None

Delete a key from a table.

Parameters:

  • table (str): Table name
  • key (bytes): Key data

Raises:

  • RuntimeError: If deletion fails

count(table: str) -> int

Count rows in a table.

Parameters:

  • table (str): Table name

Returns:

  • int: Number of rows

Raises:

  • RuntimeError: If operation fails

flush() -> None

Flush database to disk.

Raises:

  • RuntimeError: If flush fails

close() -> None

Close the database and free resources.

Examples

See the examples/ directory for more examples:

  • basic_crud.py: Basic CRUD operations

Requirements

  • Python 3.8+
  • Rust toolchain (for building from source)

License

Dual-licensed under:

  • MIT License — for open-source projects
  • Commercial License — for proprietary/commercial use

See LICENSE for details.

For commercial licensing inquiries, contact: ByteLogicCore

Metadata

Release files for dbx-py 0.2.2

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

Source distribution (sdist)

Source distribution for dbx-py 0.2.2
File Size Uploaded
dbx_py-0.2.2.tar.gz 9.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbx-py 0.2.2
File Interpreter ABI Platform
dbx_py-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 MB

Release files / dbx_py-0.2.2.tar.gz

Download URL dbx_py-0.2.2.tar.gz
Size 9.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0a3626edd2cfcf1fae3cd6d9f782b5781e807cb5360c107d875af718ec0ed474
BLAKE2b-256 checksum
How to use checksums
dba7b97be925162d5957d5771475169c660233ca6608cf6395e40ec593c3bedb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / dbx_py-0.2.2-py3-none-any.whl

Download URL dbx_py-0.2.2-py3-none-any.whl
Size 9.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7c467c23f067e6ba91d8ad09d2a2c7a5b7177082be3bc0ea3598c46332d0bddb
BLAKE2b-256 checksum
How to use checksums
b5541b2ec87313612e5aba328267919e59663093a2144b9f9180601751cc9972
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20
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