0

I have a line of code thate give me this error: DataError: integer out of range

The line of code is this :

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

I have created the table and columns with this command:

CREATE TABLE Users_Chat (Chat INT, User INT, Name TEXT, Id INT);
9
  • Extra comma at the end? Commented Sep 4, 2018 at 17:32
  • no, this not the problem, i tryed also without the comma and space at the end Commented Sep 4, 2018 at 17:35
  • what values do you have for chat_version, user_id, name_user? Commented Sep 4, 2018 at 17:41
  • is this inside a function and you pass those values? because postgress is expecting numbers, and probably you are passing something else. Commented Sep 4, 2018 at 17:41
  • oh, in chat_version is a number but start with a - is possible for this? I worked only with sqlite and it worked with him. Like this -1234 Commented Sep 4, 2018 at 17:48

1 Answer 1

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

Expects only numeric/ingegers values according to doc.

Python numeric objects int, long, float, Decimal are converted into a PostgreSQL numerical representation:

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.