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.1.1.tar.gz (13.9 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.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_kevo-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 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.1.1.tar.gz
Algorithm Hash digest
SHA256 2a0a7f6d912678bc23c9f9ab42079315ddb03869203bc06f3aeed2883a6bd146
MD5 bab70dcec5bb1e60ee5434ef4152ac23
BLAKE2b-256 29643bd2d4bf53636baca39cc271a0b8c0af4434635c78f73b1bb83324665097

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_kevo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fed3b23aaf21adb35e27c6b866bbafd8e111cc2585d19469d85c90aba0218e1
MD5 426845a437126a68aca22d3ce4fdf503
BLAKE2b-256 c58dfa5fccd0269adf25cc17a5496c644644073160eb95a2979eb147d6af21ee

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