an certain anagrafica has another parent which conflicts delete-orphan. The anagrafica's relationship may has done by just setting anagrafica.azienda_pk (not by azienda.anagrafica_set.append )
(Sorry about that separated mail...my mistake.) Regards, Tate -----Original Message----- From: "Tate Kim" <[email protected]> Date: Fri, 24 Feb 2012 17:56:44 To: <[email protected]> Reply-To: [email protected] Subject: Re: [sqlalchemy] on delete cascade Hi, jo. At first, try with cascade option 'all, delete' (note that dropped 'delete-orphan'). Second, I've ever been your situation before, maybe -----Original Message----- From: jo <[email protected]> Sender: [email protected] Date: Fri, 24 Feb 2012 11:41:48 To: sa<[email protected]> Reply-To: [email protected] Subject: [sqlalchemy] on delete cascade Hi all, I'm trying to delete cascade a linked row without success. Could anyone give me some help? This is my mapper: mapper(Azienda, tbl['azienda'], properties = { 'anagrafica': relation(Anagrafica, cascade='all, delete, delete-orphan'), }) the table Azienda has a foreign key (not null) linked to table Anagrafica. When I try to delete a row from Azienda I would like remove also the linked row in table Anagrafica... and I supposed it was done by the instruction on properties: 'anagrafica': relation(Anagrafica, cascade='all, delete, delete-orphan')... but it doesn't work... record = Azienda.get( 867 ) session.delete(record) IntegrityError: ('(IntegrityError) update or delete on table "anagrafica" violates foreign key constraint "azienda_id_anagrafica_fkey" on table "azienda" DETAIL: Key (id)=(313836) is still referenced from table "azienda". , <bound method Controller.save of <sicer.BASE.controller.anagraficaAlta.azienda.Controller object at 0x8fde590>>) 'DELETE FROM anagrafica WHERE anagrafica.id = %(id)s' {'id': 313836} Thanks for any help j -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
