postgresql with python psycopg DataError:整数超出范围

问题描述 投票:0回答:1

我有一行代码thate给我这个错误:DataError: integer out of range

代码行是这样的:

c.execute("INSERT INTO Users_Chat (Chat, User, Name, Id) VALUES (%s, %s, %s, %s)", (chat_version, user_id, name_user, 0, ))

我用这个命令创建了表和列:

CREATE TABLE Users_Chat (Chat INT, User INT, Name TEXT, Id INT);
python postgresql psycopg2
1个回答
0
投票
c.execute("INSERT INTO Users_Chat (Chat, User, Name, Id) VALUES (%s, %s, %s, %s)", (chat_version, user_id, name_user, 0, ))

根据doc,只考虑数字/入侵者值。

Python数字对象int,long,float,Decimal转换为PostgreSQL数值表示:

https://www.postgresql.org/docs/current/static/datatype-numeric.html

© www.soinside.com 2019 - 2024. All rights reserved.