A Python package for interacting with the opengemini
Project description
opengemini-client-python
English | 简体中文
opengemini-client-python is a Python client for OpenGemini
Design Doc
About OpenGemini
OpenGemini is a cloud-native distributed time series database, find more information here
Requirements
- Python 3.9+
Usage
Install:
pip install opengemini_client
Getting Started:
from opengemini_client import Client, Config, Address
if __name__ == "__main__":
config = Config(address=[Address(host='127.0.0.1', port=8086)])
cli = Client(config)
try:
cli.ping(0)
print("ping success")
except Exception as error:
print(f"ping failed, {error}")
Create a database:
from opengemini_client import Client, Config, Address
if __name__ == "__main__":
config = Config(address=[Address(host='127.0.0.1', port=8086)])
cli = Client(config)
try:
database = 'test'
res = cli.create_database(database=database)
if res.error is None:
print(f"create database {database} success")
else:
print(f"create database {database} failed, {res.error}")
except Exception as error:
print(f"create database {database} failed, {error}")
Write points:
from opengemini_client import Client, Config, Address, Point, BatchPoints, Precision
if __name__ == "__main__":
config = Config(address=[Address(host='127.0.0.1', port=8086)])
cli = Client(config)
try:
database = 'test'
measurement = 'test_measurement'
point = Point(
measurement=measurement,
precision=Precision.PrecisionSecond,
fields={'Humidity': 87, 'Temperature': 25},
tags={'Weather': 'foggy'}
)
batch_points = BatchPoints(points=[point])
cli.write_batch_points(database=database, batch_points=batch_points)
print(f"write points success")
except Exception as error:
print(f"write points failed, {error}")
Do a query:
from opengemini_client import Client, Config, Address, Query
if __name__ == "__main__":
config = Config(address=[Address(host='127.0.0.1', port=8086)])
cli = Client(config)
try:
database = 'test'
measurement = 'test_measurement'
query = Query(
database=database,
command=f'select * from {measurement}',
retention_policy=''
)
res = cli.query(query=query)
if res.error is not None:
print(f"query error, {res.error}")
else:
for result in res.results:
if result.error is not None:
print(f"query result error, {result.error}")
continue
for s in result.series:
print(f"name={s.name}, columns={s.columns}, values={s.values}")
except Exception as error:
print(f"query failed, {error}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opengemini_client-0.1.0.tar.gz.
File metadata
- Download URL: opengemini_client-0.1.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f85f20ecc60ddb35519c47250ccd07b2496f136f3e94e714001d2a3aaf0cb86
|
|
| MD5 |
45d2e26f6a5751709c17634f5963e6a2
|
|
| BLAKE2b-256 |
9efb781bc375fa307527497ac02e8f9cff210adaa3eba0c052b30e7034a6dc5e
|
File details
Details for the file opengemini_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opengemini_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f0194ec33f10faebefd50e6afbd02da08e1087ba620de8b760fd38b862e60d5
|
|
| MD5 |
34056326ab355517aa5ca877293b72c6
|
|
| BLAKE2b-256 |
a5d4410939577a8bedbe75dba0d5a348ec2b3facf4db103e867938b2ae193df2
|