5

I am using line protocol and Python to write into InfluxDB. Below is the code that creates DB and working fine.

 client = InfluxDBClient(host, port, user, password, dbname)
    print("Creating database: " + dbname)
    client.create_database(dbname)
    print("Database created: " + dbname)

I want to write below mention sample data using Line protocol into influxDB

Sample lines of data of Line protocol looks like

interface,path=address,element=link value=3
interface,path=address,element=link value=7
interface,path=address,element=link value=4

I am using latest version of InfluxDB which supports line protocol.

Any idea about how the client.write statement looks like for python client?

2
  • In Java i can do this easily influxDB.write(dbName, "default",InfluxDB.ConsistencyLevel.ALL,"interface,path=address,element=link value=4"); I need the same in python Commented Aug 25, 2016 at 1:21
  • 1
    github.com/influxdata/influxdb-python Commented Mar 17, 2017 at 10:42

1 Answer 1

8

You can use line protocol from python3 to insert data.

    >>> from influxdb import InfluxDBClient 
    >>> client = InfluxDBClient(host='127.0.0.1', port=8086, username='admin', password='password', ssl=False, verify_ssl=False)
    >>> client.write(['interface,path=address,elementss=link value=3'],{'db':'yourdb'},204,'line')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.