Hello, everyone,

Let's say I have a class like this:

Class Foo(...):
    id = Column('id', Sequence('id_seq'), primary_key=True)
    color = Column(...)
    size = Column(...)

How do I instantiate one of these Foo objects without specifying an id for it 
(letting it come from the id_seq sequence) and have immediate access to its 
'id' attribute value before I commit the session? In other words, what I'd like 
to do is this:

new_foo = Foo(color='blue', size='large')  # do not specify id
print(new_foo.id)  # at this point, new_foo is a Foo, but new_foo.id is None!

I've tried putting FetchedValue() on the Foo.id column, and I've tried flushing 
the session before accessing new_foo.id, but neither of those things seem to 
work.

Thanks for your time and reply,
Mike

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to