Skip to content
All lessons

Tech Insights

"DataError: integer out of range" in psycopg may be caused when you have a table with an integer auto-incrementing id and you...

"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.

Shared by

  • PostgreSQL
  • Psycopg

Book a call

Lessons like this one
shape how we build.

Tell us what you’re building. In one call, we’ll show you how our team would approach it.

Tell us what you’re building, and we’ll show you how we’d approach it.

Still prefer the good old email? Contact us