Thank you, I now experiment with putting session.add and session.flush in object.__init__ ..
Are there any general disadvantages of that approach? On Apr 3, 7:44 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > Integer primary key identifiers are generated by the database itself using a > variety of techniques which are all database-dependent. This process occurs > when the session flushes. > > If you read the object relational tutorial starting > athttp://www.sqlalchemy.org/docs/orm/tutorial.html#setting-up-the-mappingand > working down through the end > ofhttp://www.sqlalchemy.org/docs/orm/tutorial.html#adding-new-objectsyou will > see that this interaction is described. > > You can of course set .id to any value you'd like and that will be the value > used when the flush happens. > > On Apr 3, 2011, at 1:09 PM, farcat wrote: > > > > > > > > > Hi all, > > > I use a kind of dynamic reference from parent_table to other tables. > > For that parent_table uses columns table_name and a record_id. This > > makes it possible to have a reference from parent_table to any record > > in any table in the database. However, say that i want to reference a > > record of table_name, i need the record.id to initialize > > parent_table.record_id. However, when i create a record and > > session.add it to the database, record.id == None. > > > I was wondering when and how record.id is initialized and how it can > > be forced. > > > Cheers, Lars > > > -- > > 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 > > athttp://groups.google.com/group/sqlalchemy?hl=en. -- 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.