Lessons Learned

Daily drops of knowledge from the Vinta team

contact us
Back to Lessons Learned
Postgres Psycopg

DataError: integer out of range in psycopg may be caused when you have a table with an integer auto-incrementing id and you insert more than 2^31-1 records. Note that if you TRUNCATE the table, the id sequence DOES NOT reset. Use ALTER SEQUENCE sequence-name RESTART WITH 1; for that. Find out the sequence name with \d+ table_name.

About Flávio Juvenal

Controversial software developer who questions everything: "Are we really going forward?". Python enthusiast, but is afraid JavaScript will conquer the world. Enjoys working with Django and now wants to write system checks for everything on it.