On Jul 7, 2009, at 9:23 PM, Michael Mileusnich wrote:
> To get foreign keys in my python app I am doing the following: > > ForeignKeyConstraint(['USERID'], ['USERS.USERID'], ondelete="CASCADE") I would suggest using lowercase names there, i.e. "userid", "users.userid", which indicates a case insensitive identifier, unless those names are case-sensitively quoted as uppercase (if you're using Oracle, its likely they are case insensitive names and you'll want to specify them as lowercase on the SQLA side). > and my mappers are nothing more than mapper(class, table). Is there > anything wrong with not defining the relation in the mapper as well? There's no problem as long as you populate/null out as appropriate all foreign key attributes yourself before flushing, if you're flushing things. If you have CASCADE rules in effect on your database, you won't see new values unless you expire the objects (happens automatically after a commit()). Alternatively you can place a FetchedValue marker on those columns which will auto-expire them after a flush, see the metadata docs for details (don't mix this with relation() for the same column though). > Also, is there a way for sqlalchemy to manage cascades for databases > that do not support it (sql-lite, etc)? SQLAlchemy does do cascades within the ORM, but that functionality takes place through relation()s configured to do so. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. 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 -~----------~----~----~----~------~----~------~--~---