2024-05-19 11:31:01 发布
网友
我在插入PostgreSQL时遇到问题。 我试图插入的列是JSONB类型。 对象的类型为Counter()
在生产中,它可以工作,但在本地我有一个问题
错误是: asyncpg.exceptions.DataError:查询参数$16:Counter({'clearmeleva':1,'Cr7Fluence…(预期为str,获得计数器)的输入无效。
谢谢大家!
如asyncpg documentation中所述,JSON和JSONB对应的Python类型是string。 因此,如果要添加数据的列的类型为JSONB,请尝试将Counter-type对象转换为string
JSON
JSONB
string
Counter-type
new_counter_type_obj = str(counter_type_obj)
然后将其传递给asyncpg
如asyncpg documentation中所述,
JSON
和JSONB
对应的Python类型是string
。因此,如果要添加数据的列的类型为
JSONB
,请尝试将Counter-type
对象转换为string
然后将其传递给asyncpg
相关问题 更多 >
编程相关推荐