Skip to main content

Community Python client for InfluxDB IOx (CLI)

Project description

About

This is a community repository of Python code for InfluxDB with IOx. While this code is built on officially supported APIs, the library and CLI here are not officially support by Influx Data.

When installed, you have access to 2 pieces of functionality:

  1. A CLI for reading and writing data to InfluxDB with IOx.
  2. A client library for reading and writing data to InfluxDB with IOx.

Install

To install only the client:

python3 -m pip install pyinflux3

To install the client and CLI:

sudo python3 -m pip install "pyinflux3[cli]"

*Note: Use sudo if you would like to directly install the client onto your path. Otherwise use the --user flag.

Add a Config

You can drop a config file called config.json in the directory where you are running the influx3 command:

{
{
    "my-config": {
        "database": "your-database",
        "host": "your-host",
        "token": "your-token",
        "org": "your-org-id",
        "active": true
    }
}
}

Or you can use the config command to create or modify a config:

% influx3 config --name="my-config" --database="<database or bucket name>" --host="us-east-1-1.aws.cloud2.influxdata.com" --token="<your token>" --org="<your org ID>"

If you are running against InfluxDB Cloud Serverless, then use the bucket name for the database in you configuration.

Run as a Command

% influx3 sql "select * from anomalies"
% influx3 write testmes f=7 

Query and Write Interactively

% influx3
Welcome to my IOx CLI.

(>) sql
(sql >) select * from anomalies
    check    id  observed                          time     type user_id  value
0       1  None       NaN 2023-02-03 20:56:57.513279776    error       1  400.0
1       1  None       NaN 2023-02-03 17:52:54.328785835  latency       1  900.0
(>) write 
testmes f=5 boring-observability

Write from a File

Both the InfluxDB CLI and Client libary support writing from a CSV file. The CSV file must have a header row with the column names. The there must be a column containing a timestamp. Here are the parse options:

  • --file - The path to the csv file.
  • --time - The name of the column containing the timestamp.
  • --measurment - The name of the measurment to store the CSV data under. (Currently only supports user specified string)
  • --tags - (optional) Specify an array of column names to use as tags. (Currently only supports user specified strings) for example: --tags=host,region
influx3 write_csv --file ./Examples/example.csv --measurement table2 --time Date --tags host,region

Client library

This project also includes a new client library that strives for utter simplicity. It includes 3 functions, a constuctor, write(), and read().

Contribution

If you are working on a new feature for either the CLI or the Client Libary please make sure you test both for breaking changes. This can currently be achived using the following method:

python3 -m venv .venv
source .venv/bin/activate
chmod +x ./test/test-package.sh 
./test/test-package.sh 

Any time you make changes in your code and want to retest just run the script again:

./test/test-package.sh 

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

pyinflux3-cli-0.8.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

pyinflux3_cli-0.8.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file pyinflux3-cli-0.8.3.tar.gz.

File metadata

  • Download URL: pyinflux3-cli-0.8.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pyinflux3-cli-0.8.3.tar.gz
Algorithm Hash digest
SHA256 49dea69f39e850ff18961713774509d5599bbcc338d9739990119d3282a93109
MD5 76b8c447ce807be077decd3d6d4cc067
BLAKE2b-256 dee5fbbbe991877ad9c9634e6792f447be6516beaf7a86300d45c30ad464c28d

See more details on using hashes here.

File details

Details for the file pyinflux3_cli-0.8.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pyinflux3_cli-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5df91815a56537c6d144ec21259273f6bbf85467fa87d40c9cbfabecdb6a966b
MD5 5b4df8884b515eae30ea39d0109b6466
BLAKE2b-256 972bc0b53b07f7e629d875c6897af4c10c177fd192e633cca012da96a06a30c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page