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, prefix, and suffix 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()}")
    
# Scan with suffix
for kv in client.scan(ScanOptions(suffix=b".jpg")):
    print(f"Image: {kv.key.decode()}, Description: {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.3.2.tar.gz (22.0 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.3.2-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_kevo-0.3.2.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python_kevo-0.3.2.tar.gz
Algorithm Hash digest
SHA256 3cebfe4d7a560ad887d4f48d60de970407cd9fb2d4fef4816739d918856c60dd
MD5 b7329aeb6929ee50aad9929eedf1d4dc
BLAKE2b-256 2a818d7515d6614e5a24ff3ab6b0a5d6fc8db5538a1f1a490ffb21c358f65b10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_kevo-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python_kevo-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 474ce6c9adb408aed67d8d2d3164e88c581353fcb086a1fa6dc4dcaed5db3312
MD5 42491b5bf4ec424b39ad9fa4d30d5f64
BLAKE2b-256 8b22063600b24980e3d981a2e92073f8c6efc4f5c6c789b61ee57e3412dcf756

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