On 27 Jul 2009, at 16:32, Michael Bayer wrote: > > what's "elegant" to me is: > >>>> f = Foo() >>>> Session.add(f) >>>> Session.flush() # or commit >>>> f.bar > True > > consider that Foo() wouldn't know about server generated defaults if > not > associated with the database. The database association is achieved > using > Session.add(). >
Ah thanks, that works great and makes perfect sense. Only issue now is that if you have a NOT NULL constraint on a field, an IntegrityError exception gets raised when flush() is called. One way round this is to supply a dummy value for the field in question. Is there a better way to prevent the exception? Jamie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
