我有一行代码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);
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