redistimeseries-py icon indicating copy to clipboard operation
redistimeseries-py copied to clipboard

how to store a dictionary? and retrieve using range command

Open shan4usmani opened this issue 2 years ago • 1 comments

Hi,

I am using Redis for the first time so I don't have a lot of understanding of how this works in python. I have a dictionary with multiple keys along with a time key. I need to save the data in Redis and then retrieve multiple data points using the range function.

data = {'timestamp': 124567889, 'datetime' :9/27/2018 9:04, 'sensor1': 34, 'sensor2': 56, 'sensor3': 90,'sensor4' : 12}

Issue 1:

how can I save this using the Redis time series module?

currently i am creating seperate time series for every sensor :

rts.create(sensor1, labels = {'time':'series'},duplicate_policy='last') rts.create(sensor2, labels = {'time':'series'},duplicate_policy='last')

and then adding individual values to each time series : rts.add(sensor1,unixtime,34) rts.add(sensor2,unixtime,56)

I will have more than 100 different values in the next stage and my current method takes some time to save the data. so is there an easier way where I can save all values together without having to create and save each value individually?

Issue 2:

Also, I am trying to retrieve the data using the range function in the following manner:

rts.range('datetime',start_time,end_time)

but when the date is returned it just says '9.0' instead of complete date '9/272018 9:04'.

any help would be much appreciated.

Thank You.

shan4usmani avatar Oct 12 '21 21:10 shan4usmani

Hi, Can you please send us a script which reproduce the problem? It's not clear what are the exact parameters you used in the unixtime and the start_time and end_time.

Thanks in advance!

OfirMos avatar Oct 14 '21 06:10 OfirMos