I'm using the declarative approach to build a database using sqlalchemy in a flask application. If I initialize the database and run my program everything works fine. I am able to add data to the db with no issues and the primary key (id) is incremented appropriately. But if I copy and paste data from another db and then try to run my code to add an item I get this error:
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "printers_pkey" DETAIL: Key (id)=(1) already exists.
I believe it is because upon adding an item the primary key (id) starts from 1 instead of picking up where the id left off. It is not aware that anything has been added outside of my program. I cannot find anything on how to go about getting my program to know that there is data in the table and to pickup where the id is left off.