It works!
Thanks a lot, Tate.

j

Tate Kim wrote:
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



--
Jose Soares _/_/ Sferacarta Net Via Bazzanese 69 _/_/ _/_/_/
40033 Casalecchio di Reno             _/_/   _/_/  _/_/
Bologna - Italy                      _/_/   _/_/  _/_/
Ph  +39051591054              _/_/  _/_/   _/_/  _/_/
fax +390516131537            _/_/  _/_/   _/_/  _/_/
web:www.sferacarta.com        _/_/_/       _/_/_/

Le informazioni contenute nella presente mail ed in ogni eventuale file 
allegato sono riservate e, comunque, destinate esclusivamente alla persona o 
ente sopraindicati, ai sensi del decreto legislativo 30 giugno 2003, n. 196. La 
diffusione, distribuzione e/o copiatura della mail trasmessa, da parte di 
qualsiasi soggetto diverso dal destinatario, sono vietate. La correttezza, 
l’integrità e la sicurezza della presente mail non possono essere garantite. Se 
avete ricevuto questa mail per errore, Vi preghiamo di contattarci 
immediatamente e di eliminarla. Grazie.

This communication is intended only for use by the addressee, pursuant to 
legislative decree 30 June 2003, n. 196. It may contain confidential or 
privileged information. You should not copy or use it to disclose its contents 
to any other person. Transmission cannot be guaranteed to be error-free, 
complete and secure. If you are not the intended recipient and receive this 
communication unintentionally, please inform us immediately and then delete 
this message from your system. Thank you.

--
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.

Reply via email to