influxobject


Nameinfluxobject JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://gitlab.com/m-unlock/influx-object
SummaryInflux Object Package
upload_time2024-03-09 16:19:23
maintainer
docs_urlNone
authorJasper Koehorst, Brett Metcalfe
requires_python>=3.6
license
keywords influx json package
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Influx Point

## Description

This module enables the creation of an influx point object that can be transformed into either a JSON or LineProtocol format.

### Features

#### InfluxDB Line Protocol Format

The InfluxDB Line Protocol is a text-based format designed for the efficient writing of time-series data into InfluxDB. It organizes the data points with timestamps, measurement names, fields (key-value pairs representing the data), and tags (optional key-value pairs used to store metadata that describes the data). The format is highly optimized for time-series data, enabling quick parsing and writing. A typical line in this format looks like this:

> measurementName,tagKey=tagValue fieldKey="fieldValue" 1465839830100400200

- measurementName: Identifies the measurement.
- tagKey=tagValue: Zero or more tag sets separated by commas. Tags are optional but recommended for indexing.
- fieldKey="fieldValue": At least one field set, with multiple fields separated by commas. Fields are the actual data points.
- 1465839830100400200: An optional timestamp for the data point. If not specified, the server's current time is used.

### JSON Format

The JSON format offers a more flexible way to represent data. 

```json
{
    "measurement": "measurement",
    "tags": {"tag1": "value1"},
    "fields": {"field1": 1, "field2": 2},
    "timestamp": 1609455600,
}
```

## Usage

```python

    from influxobject.influxpoint import InfluxPoint

    influx_point = InfluxPoint()
    influx_point.set_measurement("measurement")
    influx_point.set_tags({"tag1": "value1"})
    influx_point.set_fields({"field1": 1, "field2": 2})
    influx_point.set_timestamp(datetime.datetime(2021, 1, 1))\
    
    print(influx_point.to_json())

        # {
        #     "measurement": "measurement",
        #     "tags": {"tag1": "value1"},
        #     "fields": {"field1": 1, "field2": 2},
        #     "timestamp": 1609455600,
        # }
        
    print(influx_point.to_line_protocol())

        # "measurement,tag1=value1 field1=1,field2=2 1609455600"
```

## Installation

To install the package use the pip package manager

```bash
    pip install influxobject
```

## Development

Tox is used as the test runner for this project. To run the entire tox suite use the following command:

```bash
    tox
```

To only run the tests under python 3.9

```bash
    tox -e py39
```

Build

```bash
    python setup.py sdist
```

Publish

```bash
    twine upload dist/*
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/m-unlock/influx-object",
    "name": "influxobject",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "influx,json,package",
    "author": "Jasper Koehorst, Brett Metcalfe",
    "author_email": "jasper.koehorst@wur.nl",
    "download_url": "https://files.pythonhosted.org/packages/3d/f8/d3c967d1181e1092c252612d4e1caa78cb8b72cff4fef62ead3b4802ef53/influxobject-0.0.3.tar.gz",
    "platform": null,
    "description": "# Influx Point\n\n## Description\n\nThis module enables the creation of an influx point object that can be transformed into either a JSON or LineProtocol format.\n\n### Features\n\n#### InfluxDB Line Protocol Format\n\nThe InfluxDB Line Protocol is a text-based format designed for the efficient writing of time-series data into InfluxDB. It organizes the data points with timestamps, measurement names, fields (key-value pairs representing the data), and tags (optional key-value pairs used to store metadata that describes the data). The format is highly optimized for time-series data, enabling quick parsing and writing. A typical line in this format looks like this:\n\n> measurementName,tagKey=tagValue fieldKey=\"fieldValue\" 1465839830100400200\n\n- measurementName: Identifies the measurement.\n- tagKey=tagValue: Zero or more tag sets separated by commas. Tags are optional but recommended for indexing.\n- fieldKey=\"fieldValue\": At least one field set, with multiple fields separated by commas. Fields are the actual data points.\n- 1465839830100400200: An optional timestamp for the data point. If not specified, the server's current time is used.\n\n### JSON Format\n\nThe JSON format offers a more flexible way to represent data. \n\n```json\n{\n    \"measurement\": \"measurement\",\n    \"tags\": {\"tag1\": \"value1\"},\n    \"fields\": {\"field1\": 1, \"field2\": 2},\n    \"timestamp\": 1609455600,\n}\n```\n\n## Usage\n\n```python\n\n    from influxobject.influxpoint import InfluxPoint\n\n    influx_point = InfluxPoint()\n    influx_point.set_measurement(\"measurement\")\n    influx_point.set_tags({\"tag1\": \"value1\"})\n    influx_point.set_fields({\"field1\": 1, \"field2\": 2})\n    influx_point.set_timestamp(datetime.datetime(2021, 1, 1))\\\n    \n    print(influx_point.to_json())\n\n        # {\n        #     \"measurement\": \"measurement\",\n        #     \"tags\": {\"tag1\": \"value1\"},\n        #     \"fields\": {\"field1\": 1, \"field2\": 2},\n        #     \"timestamp\": 1609455600,\n        # }\n        \n    print(influx_point.to_line_protocol())\n\n        # \"measurement,tag1=value1 field1=1,field2=2 1609455600\"\n```\n\n## Installation\n\nTo install the package use the pip package manager\n\n```bash\n    pip install influxobject\n```\n\n## Development\n\nTox is used as the test runner for this project. To run the entire tox suite use the following command:\n\n```bash\n    tox\n```\n\nTo only run the tests under python 3.9\n\n```bash\n    tox -e py39\n```\n\nBuild\n\n```bash\n    python setup.py sdist\n```\n\nPublish\n\n```bash\n    twine upload dist/*\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Influx Object Package",
    "version": "0.0.3",
    "project_urls": {
        "Bug Reports": "https://gitlab.com/m-unlock/influx-object/-/issues",
        "Documentation": "https://gitlab.com/m-unlock/influx-object",
        "Homepage": "https://gitlab.com/m-unlock/influx-object",
        "Source Code": "https://gitlab.com/m-unlock/influx-object"
    },
    "split_keywords": [
        "influx",
        "json",
        "package"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3df8d3c967d1181e1092c252612d4e1caa78cb8b72cff4fef62ead3b4802ef53",
                "md5": "e62423783deb74694d6147fb20e19ac1",
                "sha256": "d01e7eda7d6d6a8dd3032b508ec4f9c6863ed78328bff180112218f373cd3c08"
            },
            "downloads": -1,
            "filename": "influxobject-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "e62423783deb74694d6147fb20e19ac1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6527,
            "upload_time": "2024-03-09T16:19:23",
            "upload_time_iso_8601": "2024-03-09T16:19:23.123520Z",
            "url": "https://files.pythonhosted.org/packages/3d/f8/d3c967d1181e1092c252612d4e1caa78cb8b72cff4fef62ead3b4802ef53/influxobject-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-09 16:19:23",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "m-unlock",
    "gitlab_project": "influx-object",
    "lcname": "influxobject"
}
        
Elapsed time: 0.20225s