Arrays 编程错误:运算符不存在:bigint[]=integer[]

Arrays 编程错误:运算符不存在:bigint[]=integer[],arrays,python-3.x,postgresql,psycopg2,Arrays,Python 3.x,Postgresql,Psycopg2,我正在使用Python3和Postgres包 我有一个表,其中一列是bigint数组。当我尝试使用python数字列表来处理这个列select、insert等时,我得到了一个错误 错误的原因似乎是psycopg2将列表调整为整数数组而不是大整数。它建议显式强制转换,但我在psycopg2文档中找不到如何做到这一点。当我传递的数字列表太大,无法容纳4个字节(整数大小)时,错误就会消失 这是我运行的代码: db.allSELECT来自收件人=%repss,{reps':[12,34]}的邮件的阶段

我正在使用Python3和Postgres包

我有一个表,其中一列是bigint数组。当我尝试使用python数字列表来处理这个列select、insert等时,我得到了一个错误

错误的原因似乎是psycopg2将列表调整为整数数组而不是大整数。它建议显式强制转换,但我在psycopg2文档中找不到如何做到这一点。当我传递的数字列表太大,无法容纳4个字节(整数大小)时,错误就会消失

这是我运行的代码:

db.allSELECT来自收件人=%repss,{reps':[12,34]}的邮件的阶段

以下情况也会发生:

db.allSELECT-phase-from-messages,其中recipients=ARRAY[12,34]

这是我收到的错误信息:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yoni/.local/lib/python3.6/site-packages/postgres/__init__.py", line 552, in all return cursor.all(sql, parameters) File "/home/yoni/.local/lib/python3.6/site-packages/postgres/cursors.py", line 145, in all self.execute(sql, parameters) File "/home/yoni/.local/lib/python3.6/site-packages/psycopg2/extras.py", line 313, in execute return super(NamedTupleCursor, self).execute(query, vars) psycopg2.ProgrammingError: operator does not exist: bigint[] = integer[] LINE 1: SELECT phase from messages where recepients=ARRAY[12,34] ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts. 将数组强制转换为bigint[]:

db.all("SELECT phase from messages where recipients=ARRAY[12, 34]::bigint[]")