influxdata / influxdb-python

Python client for InfluxDB
MIT License
1.7k stars 522 forks source link

Is it possible to directly use timestamps in epoch format? #880

Open bijwaard opened 3 years ago

bijwaard commented 3 years ago

My sensor uses UTC epoch timestamps as a floating point number in seconds including nanoseconds, would it be possible to use them directly with influxdb-python without first converting them to string format? I understand that influx itself uses the EPOCH format as 64bits nanoseconds, so I could just multiply my timestamp by 10^9.

I currently convert timestamps via strftime which is not so efficient since the library will convert it back. timestamp="%s.%09dZ"%(time.strftime('%Y-%m-%dT%H:%M:%S',time.gmtime(my_ts)),(my_ts%1)*1000000000)

Kind regards, Dennis