rajasekhar911 wrote: > > Hi > > I am facing a different problem in inheritance. > I am using the single table inheritance through declarative. > http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#single-table-inheritance > > b=Base() > b.id='xxx' > b.name='xxx' > b.type='type1' > I am manually setting the type column of my base class. > but when i try to commit,it gives the IntegrityError > base.type may not be NULL u'INSERT INTO bases (id, name, type, > address, login, password) VALUES (?, ?, ?, ?, ?, ?)' ['xxx', 'xxx', > None, None, 'xxx','xxx']
it sounds like your configuration is missing polymorphic_on. you can't manually set the "type" column. > > I checked this thread, > http://groups.google.com/group/sqlalchemy/browse_thread/thread/c646007dce37b11a > but I dont have access to the subclass to set the __class__ it sounds like you may be using single table inheritance for a purpose which it was not designed. If you don't the desired subclass available at the time of Session.add(), then you don't really need class inheritance in any case. Also I dont really understand what "I don't have access" means, if you were able to map the class then you should be able to import it. If you just dont "know" what type "x" links to what class, store them in a dict somewhere. > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---