[sqlalchemy] Re: default values in reflected tables

2009-07-27 Thread Michael Bayer
Jamie Bullock wrote: > > > > 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? thats wh

[sqlalchemy] Re: default values in reflected tables

2009-07-27 Thread Jamie Bullock
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 asso

[sqlalchemy] Re: default values in reflected tables

2009-07-27 Thread Michael Bayer
Jamie Bullock wrote: > > > Hi, > > Is there a way in SQLalchemy to have the values of a mapped reflected > table object set to default column values derived from the database > backend? > > e.g. if column 'bar' of table 'foo' in my database has a default of > "True", I would like to be able to do