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.1.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.1-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_kevo-0.3.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for python_kevo-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ef12ebd0e3bef3fef7f395ab15044d4ad6553eb4f398eff7c87355b5964650da
MD5 10debb6e3e1a52d96ddcd6b83d370c06
BLAKE2b-256 ff8c2416f1d844449d0b4f858e07e2be2bf426aa2ba0ad1ed2ffeee64e2e7785

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_kevo-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 958ce48ed212956e07538f46d4244c4ec838c9e7bdfb28cb185d3467802c2fb9
MD5 b48ddee5127234321887d38bea62f44e
BLAKE2b-256 3b3ed19457aeeeaba0279be57251e12b15a2653060e079be3721d0276db13945

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