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 at 
http://www.sqlalchemy.org/docs/orm/tutorial.html#setting-up-the-mapping and 
working down through the end of 
http://www.sqlalchemy.org/docs/orm/tutorial.html#adding-new-objects you 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 [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.
> 

-- 
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.

Reply via email to