Skip to main content

Python bindings for DBX high-performance database

Project description

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

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

dbx_py-0.1.0b0.tar.gz (3.5 MB view details)

Uploaded Source

Built Distribution

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

dbx_py-0.1.0b0-py3-none-any.whl (5.3 MB view details)

Uploaded Python 3

File details

Details for the file dbx_py-0.1.0b0.tar.gz.

File metadata

  • Download URL: dbx_py-0.1.0b0.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for dbx_py-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 e24aa67a55e1b8753317207802e83f3a4f5b991ec0b498e5059fc914901bac67
MD5 6f55b362177b618c565a790af63a992d
BLAKE2b-256 8a3150a1d14e7a8d09a490395f7b3b71295d6e13120ff998eb5b3c858929f003

See more details on using hashes here.

File details

Details for the file dbx_py-0.1.0b0-py3-none-any.whl.

File metadata

  • Download URL: dbx_py-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for dbx_py-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0037267053124c35a3dfd95054d360982eac25c3d3e37894f6b6fefd95bcaee
MD5 9d15e1547f6dadf15765c406e835c6ce
BLAKE2b-256 4901c4827378b20d7645b981538a68a9baecadd41395db4aa980f626a02f129e

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