Skip to main content

Python SDK for Kevo key-value store

Project description

🔑 Python-Kevo

PyPI version Python versions License

High-performance Python client for the Kevo key-value store.

✨ Features

  • Simple and intuitive API
  • Efficient binary protocol (gRPC)
  • Transaction support
  • Range and prefix scans
  • Batch operations

🚀 Installation

pip install python-kevo

Or install from source:

git clone https://github.com/KevoDB/python-sdk.git
cd python-sdk
poetry install

🏁 Quick Start

from kevo import Client, ClientOptions, ScanOptions

# Create a client
client = Client(ClientOptions(endpoint="localhost:50051"))
client.connect()

# Basic operations
client.put(b"hello", b"world")
value, found = client.get(b"hello")
print(value.decode() if found else "Not found")  # Prints: world

# Scan with prefix
for kv in client.scan(ScanOptions(prefix=b"user:")):
    print(f"Key: {kv.key.decode()}, Value: {kv.value.decode()}")

# Use transactions
tx = client.begin_transaction()
try:
    tx.put(b"key1", b"value1")
    tx.put(b"key2", b"value2")
    tx.commit()
except Exception as e:
    tx.rollback()
    raise e
finally:
    client.close()

📖 API Reference

Client

client = Client(options=None)

Core Methods

Method Description
connect() Connect to the server
close() Close the connection
get(key) Get a value by key
put(key, value, sync=False) Store a key-value pair
delete(key, sync=False) Delete a key-value pair

Advanced Features

Method Description
batch_write(operations, sync=False) Perform multiple operations in a batch
scan(options=None) Scan keys in the database
begin_transaction(read_only=False) Begin a new transaction
get_stats() Get database statistics
compact(force=False) Trigger database compaction

Transaction

Methods

Method Description
commit() Commit the transaction
rollback() Roll back the transaction
get(key) Get a value within the transaction
put(key, value) Store a key-value pair within the transaction
delete(key) Delete a key-value pair within the transaction
scan(options=None) Scan keys within the transaction

🛠️ Development

Prerequisites

  • Python 3.8+
  • Poetry
  • Protocol Buffer compiler

Setup

# Install dependencies
poetry install

# Generate Protocol Buffer code
python tools/generate_proto.py

# Run tests
pytest

# Run linters
black kevo
isort kevo
pylint kevo

📄 License

MIT

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

python_kevo-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

python_kevo-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file python_kevo-0.1.0.tar.gz.

File metadata

  • Download URL: python_kevo-0.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.9 Linux/6.14.2-arch1-1

File hashes

Hashes for python_kevo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cffb87679651244b7c3d7bf78d7a81d5aef62665073ee8e23aa67ac22315028e
MD5 4e238a28127952ecbfbf956f92e00b37
BLAKE2b-256 76ed45bfed7bfecbec6222b52d053291c13dd096d8930e59c2cda84aa5c341a5

See more details on using hashes here.

File details

Details for the file python_kevo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: python_kevo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.9 Linux/6.14.2-arch1-1

File hashes

Hashes for python_kevo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d79ec533ea52fb4787c3f97c91176290c51aff4fd5858bd1681396478ec1e35f
MD5 2266f3c6643562e460174b2dd829ddc8
BLAKE2b-256 eb31f1328de918eabdb0a3dc23fcafb92b57c297a7a7e02bc8437025976b5c31

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