通过redis py:DataError将postgresql timestamptz作为分数存储到redis排序集
我使用redispy将postgresqltimestz存储到redis排序集 timestamptz用作分数,数据用作值 我需要将集合按降序排序。但我无法将数据插入redis。我不知道如何转换为redis支持的格式。 代码如下:通过redis py:DataError将postgresql timestamptz作为分数存储到redis排序集,postgresql,redis,redis-py,Postgresql,Redis,Redis Py,我使用redispy将postgresqltimestz存储到redis排序集 timestamptz用作分数,数据用作值 我需要将集合按降序排序。但我无法将数据插入redis。我不知道如何转换为redis支持的格式。 代码如下: cursor.execute("select current_timestamp;"); timestamp_raw=cursor.fetchone() redis_client.zadd("stream",{data:timestamp_raw}) 错
cursor.execute("select current_timestamp;");
timestamp_raw=cursor.fetchone()
redis_client.zadd("stream",{data:timestamp_raw})
错误如下
.....\AppData\Local\Programs\Python\Python38-32\lib\site-packages\redis\connection.py", line 117, in encode
raise DataError("Invalid input of type: '%s'. Convert to a "redis.exceptions.DataError: Invalid input of type: 'tuple'. Convert to a byte, string or number first.
如何重新爱上它?在Psycopg2中,timestamptz作为datetime和FixedOffsetTimezone的元组返回 您需要将元组转换为float,以便将其用作分数 看