Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

ReductStore Client SDK for Python

License

NotificationsYou must be signed in to change notification settings

reductstore/reduct-py

Repository files navigation

PyPIPyPI - DownloadsGitHub Workflow Status

This package provides an asynchronous HTTP client for interacting withReductStore in Python.

Features

  • Supports theReductStore HTTP API v1.14
  • 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:

fromreductimportClient,BucketSettings,QuotaTypeasyncdefmain():# 1. Create a ReductStore clientasyncwithClient("http://localhost:8383",api_token="my-token")asclient:# 2. Get or create a bucket with 1Gb quotabucket=awaitclient.create_bucket("my-bucket",BucketSettings(quota_type=QuotaType.FIFO,quota_size=1_000_000_000),exist_ok=True,        )# 3. Write some data with timestamps in the 'entry-1' entryawaitbucket.write("sensor-1",b"<Blob data>",timestamp="2024-01-01T10:00:00Z",labels={"score":10})awaitbucket.write("sensor-1",b"<Blob data>",timestamp="2024-01-01T10:00:01Z",labels={"score":20})# 4. Query the data by time range and conditionasyncforrecordinbucket.query("sensor-1",start="2024-01-01T10:00:00Z",stop="2024-01-01T10:00:02Z",when={"&score": {"$gt":10}}):print(f"Record timestamp:{record.timestamp}")print(f"Record size:{record.size}")print(awaitrecord.read_all())# 5. Run the main functionif__name__=="__main__":importasyncioasyncio.run(main())

For more examples, see theGuides section in the ReductStore documentation.


[8]ページ先頭

©2009-2025 Movatter.jp