This is (part of) my mapping:
data = Table('data', metadata,
Column('id', Integer, primary_key=True),
Column('id_acq', Integer, ForeignKey('acquisitions.id'),
index=True,
nullable=False),
Column('value', Float, nullable=True),
)
acquisitions = Table('acquisitions', metadata,
Column('id', Integer, primary_key=True),
Column('datetime', DateTime, index=True, nullable=False),
)
orm.mapper(Data, data)
orm.mapper(Acquisition, acquisitions, properties={
'data': orm.relationship(Data, backref='acquisition',
cascade='all, delete-orphan', single_parent=True)
})
Now that my app is depolyed using MySQL (InnoDB) I need to add a
feature for multiple acquisitions delete.
As far as I understand I need to change relationship above adding
`passive_deletes=True`so I can perform multiple deletions without
having IntegrityError: 'Cannot delete or update a parent row: a
foreign key constraint fails' with:
Session.query(model.Acquisition).filter(...).delete(synchronize_session=False)
My questions are:
* how do I perform changes on my current MySQL db foreign key
'id_acq'? Is there a SA way or simply I have to use mysql tools?
* when I will eventually run again `paster setup-app` on a new db
will be acquisitions table built with ON DELETE CASCADE by default?
* since MySQL (InnoDB) supports ON DELETE CASCADE is it recommended I
switch on `passive_deletes=True` all my relationships so I can get
better performances?
Thanks for your support
neurino
--
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.