Hi, I was naively trying to clear a db earlier in the day and I ran into this problem: 'Cannot delete or update a parent row: a foreign key constraint fails'
So as anyone would do I've been searching online and through the documentation on how to turn the foreign keys off, on delete = Cascade, delete orphan-cascade what have you. So many hours and many stack traces later I'd like to ask your help in this matter def cleanMapping(self, dbName): > > connection = self.dbEngines[dbName].connect() > trans = connection.begin() > > for my_table in reversed(self.dbMetaData[dbName].tables.values()): > keys= my_table.foreign_keys > for column in my_table.columns: > for key in keys: > my_table = Table(my_table, self.dbMetaData[dbName], > Column(column, Integer, > ForeignKey(key, onupdate="CASCADE", ondelete = > "CASCADE") > ,primary_key=True)) > connection.execute(my_table.delete()) > > trans.commit() So I'm fresh out of ideas; Everytime I try using this code I get "sqlalchemy.exc.ArgumentError: Column object already assigned to Table <col>" -- 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/-/QM0GVC402DAJ. 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.