influxobject


Nameinfluxobject JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://gitlab.com/m-unlock/influx-object
SummaryInflux Object Package
upload_time2024-10-14 19:47:43
maintainerNone
docs_urlNone
authorJasper Koehorst, Brett Metcalfe
requires_python>=3.6
licenseNone
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"
```

All functinoalities of the InfluxPoint object are listed below:

```python
    import influxobject
    x = influxobject.InfluxPoint()
    x.
        x.add_field(..., ...)
        x.from_json(...)
        x.remove_field(...)
        x.set_measurement(...)
        x.to_line_protocol()
        x.add_tag(..., ...)
        x.remove_tag(...)
        x.set_tags(...)
        x.validate()
        x.parse_line_protocol(...)
        x.set_fields(...)
        x.set_timestamp(...)
        x.to_json()
```

## 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": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "influx, json, package",
    "author": "Jasper Koehorst, Brett Metcalfe",
    "author_email": "jasper.koehorst@wur.nl",
    "download_url": "https://files.pythonhosted.org/packages/2d/c4/e2d7d4bddd36ad58422f27026d2da2d05926884e61eb2912c7a7bbcfeded/influxobject-0.0.4.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\nAll functinoalities of the InfluxPoint object are listed below:\n\n```python\n    import influxobject\n    x = influxobject.InfluxPoint()\n    x.\n        x.add_field(..., ...)\n        x.from_json(...)\n        x.remove_field(...)\n        x.set_measurement(...)\n        x.to_line_protocol()\n        x.add_tag(..., ...)\n        x.remove_tag(...)\n        x.set_tags(...)\n        x.validate()\n        x.parse_line_protocol(...)\n        x.set_fields(...)\n        x.set_timestamp(...)\n        x.to_json()\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": null,
    "summary": "Influx Object Package",
    "version": "0.0.4",
    "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": "2dc4e2d7d4bddd36ad58422f27026d2da2d05926884e61eb2912c7a7bbcfeded",
                "md5": "b7af19fdd333dc877c760f416ca422df",
                "sha256": "c9b7005651ab80e248c518dc47ab00e0395c592db463856d4a86c495ee6d40a8"
            },
            "downloads": -1,
            "filename": "influxobject-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b7af19fdd333dc877c760f416ca422df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6914,
            "upload_time": "2024-10-14T19:47:43",
            "upload_time_iso_8601": "2024-10-14T19:47:43.695220Z",
            "url": "https://files.pythonhosted.org/packages/2d/c4/e2d7d4bddd36ad58422f27026d2da2d05926884e61eb2912c7a7bbcfeded/influxobject-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-14 19:47:43",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "m-unlock",
    "gitlab_project": "influx-object",
    "lcname": "influxobject"
}
        
Elapsed time: 1.81142s