ReductStore Client SDK for Python
This package provides an asynchronous HTTP client for interacting with ReductStore in Python.
Features
- Supports the ReductStore HTTP API v1.12
- Bucket management
- API Token management
- Write, read and query data
- Labeling records
- Batching records for read and write operations
- Subscription
- Replication management
Install
To install this package, run the following command:
pip install reduct-py
Example
Here is an example of how to use this package to create a bucket, write data to it, and read data from it:
from reduct import Client, BucketSettings, QuotaType
async def main():
async with Client("http://localhost:8383", api_token="my-token") as client:
bucket = await client.create_bucket(
"my-bucket",
BucketSettings(quota_type=QuotaType.FIFO, quota_size=1_000_000_000),
exist_ok=True,
)
await bucket.write("sensor-1", b"Record #1", timestamp="2024-01-01T10:00:00Z")
await bucket.write("sensor-1", b"Record #2", timestamp="2024-01-01T10:00:01Z")
async for record in bucket.query("sensor-1",
start="2024-01-01T10:00:00Z",
end="2024-01-01T10:00:02Z"):
print(f"Record timestamp: {record.timestamp}")
print(f"Record size: {record.size}")
print(await record.read_all())
if __name__ == "__main__":
import asyncio
asyncio.run(main())
For more examples, see the Guides section in the ReductStore documentation.