Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 28, 2023 06:24 am GMT

Introducing the New Release of ReductStore Python SDK: v1.3.0: Labels Support and More

We are happy to announce the release of version 1.3.0 of the ReductStore SDK for Python! This release introduces several new features to help users better organize and filter their data.

One of the most notable new features is the ability to attach labels to data when writing and querying. Labels are key-value pairs that can be used to classify and categorize data. For example, you might use labels to store metadata about a record, such as its md5 sum or class. To start using labels, you need the version of the ReductStore database higher than 1.3.0.

Here's an example of how to use labels when writing data:

from reduct import Clientclient = Client("https://play.reduct.store", api_token="reduct")bucket = await client.create_bucket("my_data", exist_ok=True)await bucket.write(    "entry-1", b"something", labels={"label1": 123, "label2": 0.1, "label3": "hey"})

In this example, we're attaching the labels {"label1": 123, "label2": 0.1, "label3": "hey"} to the data.

When reading data, you can access the labels that were attached to it:

# Read the data back, if no timestamp is specified, the latest record is returnedasync with bucket.read("entry-1") as record:    assert record.labels == {"label1": "123", "label2": "0.1", "label3": "hey"}    data = await record.read_all()    assert data == b"something"

Another new feature in this release is the ability to query data based on labels. The query method now accepts two new parameters, include and exclude, which allow you to filter the results of a query based on the labels attached to the data.

For example, you can use the include parameter to query for records that have specific labels:

async for record in bucket.query(        "entry-1", include={"label1": "value1", "label2": "value2"}):    # Do something with the record    pass

This query returns all records with label1 equals value1 and label2 equals to value2, and ignores all other labels.

On the other hand, you can use the exclude parameter to query for records that do not have specific labels:

async for record in bucket.query(        "entry-1", exclude={"label1": "value1", "label2": "value2"}):    # Do something with the record    pass

This query returns all records that not have label1 equals value1 and label2 equals to value2.

Additionally, You can also pass Content-Type header for read and write operations, this header will be added to all the requests that read and write data.

await bucket.write(    "entry-1", b"{'some': 'json'}", content_type="application/json")async with bucket.read("entry-1") as record:    assert record.content_type == "application/json"

With these new features, you can more easily organize and filter your data, making it easier to find the information you need. We encourage you to upgrade to this latest version of the SDK and start taking advantage of these new capabilities:

pip install reduct==1.3.0

We hope you enjoy the new features and improvements in this release, and as always, we welcome your feedback and suggestions for future updates. Don't hesitate to reach out in Discord or by opening a discussion on GitHub.

Thanks for using ReductStore!


Original Link: https://dev.to/reductstore/introducing-the-new-release-of-reductstore-python-sdk-v130-labels-support-and-more-4c25

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To