Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过redis py:DataError将postgresql timestamptz作为分数存储到redis排序集_Postgresql_Redis_Redis Py - Fatal编程技术网

通过redis py:DataError将postgresql timestamptz作为分数存储到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}) 错

我使用redispy将postgresqltimestz存储到redis排序集

timestamptz用作分数,数据用作值

我需要将集合按降序排序。但我无法将数据插入redis。我不知道如何转换为redis支持的格式。 代码如下:

  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,以便将其用作分数