I'm using Postgres as a database. I try to create new records or update existing records with data. The data is parsed from a csv file. Creating new records works fine. But when a record already exists, the update fails with: * * * IntegrityError: (IntegrityError) duplicate key value violates unique constraint "stock_item_pkey"*
I've looked at the SA documentation and as far as I can see the 'add' does an insert or an update. I've also tried updata, but that fails too and als mentions a depreciated statement. The new data is going to a single table. The PrimaryKey is the item number (item with value itemno in snippet below). Since the item is unique, I don't let Postgres create an id. *new = Item(item=itemno, ...)* *db.session.add(new)* *db.session.commit()* * * *I'm pretty new with SA and I might overlook something. How can I solve this? * -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/IC00kz76FS4J. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.