influxdb-python icon indicating copy to clipboard operation
influxdb-python copied to clipboard

Invalid time_precision is given

Open Bennofue opened this issue 8 years ago • 2 comments

I'm currently trying to insert data into InfluxDB from within python. Until it gets to "write_points" my code works pretty well so far.

While trying to insert the values i get the error: "ValueError: Invalid time precision is given. (use 'n', 'u', 'ms', 's', 'm' or 'h')"

Here is my Code:

import random
from influxdb import InfluxDBClient
batch_size = 1000

test_client = InfluxDBClient("server", port, "user", "pw", "database")

def generate_rndnr():
    
    points = []
    
    for _ in range(batch_size):
        points.append(random.randint(1, 1000))
    
    return points

points= generate_rndnr()

test_client.write_points(points, "measurement", time_precision=None)

Bennofue avatar Sep 12 '18 14:09 Bennofue

Just getting started with this library and having the same problem. It fails to run the example on the github page. Were you able to find the issue?

oldgeezy avatar Dec 16 '18 01:12 oldgeezy

It is because time_precision cannot be None if you do not want timestamps just don't use it. By default the timestamps will be stored in nanoseconds.

shantanoo-desai avatar Dec 16 '18 09:12 shantanoo-desai