On 10/28/2010 08:16 PM, anusha k wrote:
> hello all
>
> I want to know how to create Session with object_session which can be
> used to add data to the database i.e using Session.add_all().So i can
> pass a list as parameter to add_all as my length of list is of
> variable length. When i am trying to do that i was not able to
> associate instance properly and getting Session as None. I already
> gone through the below link but left with no clue. So please help me
> with this.
>
>
> http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.object_session

"object_session" only works for objects that have already been attached
to a session. To add objects to a session, you need to have the session
object available beforehand. Usually people do this using a global
"Session" variable that is created from a call to scoped_session():

Session = scoped_session(sessionmaker(some_engine))

[...]

Session.add_all([obj1, obj2, obj3])

-Conor

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