psycopg2.errors.UniqueViolation: duplicate key value violates unique constrain code example
Example: postgresql resolv duplicate value violates unique constraint
SELECT setval(pg_get_serial_sequence('users', 'id'), coalesce(max(id)+1, 1), false) FROM users;