I'm using Sqlalchemy with PostgreSQL in a project.

Some of the relations (foreign keys) in the database (postgresql) have
ON_DELETE=RESTRICT which should prevent parent objects with existing
child objects from being deleted (tested, works in pg client).

The problem is that Sqlalchemy doesn't seem to care about the
postgresql restrictions and i don't know how to let sqlalchemy obey
the postgresql rules, or let sqlalchemy work with the same
restrictions (not allowing parent instances with existing childs to be
deleted).

So, in short:
How can i implement ON_DELETE=restrict in Sqlalchemy?


An example of my current mappings:
Child_table = sa.Table('Child', metadata, autoload=True)
Parent_table = sa.Table('Parent', metadata, autoload=True)

orm.mapper(Parent,Parent_table, properties={
  'Children' :
relation(Child,primaryjoin=Parent_table.c.id==Child_table.c.parent_id,
backref=backref("Parent", remote_side=[Parent_table.c.id]))
  }
)


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