I'm aware of both methods, the later better than the former. I should
have stated that I am working with sqlalchemy.objectstore. It works
like a normal session, but since it is created automatically after
importing mods.threadlocal, there is no opportunity to bind it to an
engine as there is with create_session. Instead, it seems
metadata.connect() is the only way to bind an engine before using
sqlalchemy.objectstore. Is this correct?
I do have reasons for using sqlalchemy.objectstore rather than
create_session. I have SA result objects passed around between methods
and using objectstore is very convenient.
When using sqlalchemy.objectstore, would it be a good idea to call
objectstore.clear() (or close?) at then end of an operation? I'm
thinking a thread may serve several requests and that objectstore
persists and grows as each request and action adds more to the session
unlike a local session that is garbage-collected.
I'm learning and appreciate your help.
Randall
Michael Bayer wrote:
> On Jun 27, 2006, at 12:57 PM, Randall Smith wrote:
>
>>This makes sure each thread makes a connection. Again, this is
>>probably
>>more fit for the TG group, but it was the understanding of threadlocal
>>and metadata connections that I have been grasping for and finally
>>got.
>> Particularly that in a threadlocal context, engines are bound to
>>metadata, not sessions. Do I understand that correctly?
>
>
> randall -
>
> as it turns out, you can do it both ways; people have had needs in
> both directions.
>
> table metadata bound directly to engine:
>
> meta = DynamicMetaData()
> table =Table("sometable', meta, ...)
> meta.connect(someengine)
>
> create session as follows:
>
> sess = create_session()
>
> ----------------------------------------------------------------
> table metadata not bound to an engine:
>
> meta = MetaData()
> table =Table("sometable", meta, ...)
>
> create session as follows:
>
> sess = create_session(bind_to=someengine)
>
>
> when using the session, the engine which the Session is bound to
> takes precedence over the engine that the Table is bound to via its
> MetaData (there is also a way to even customize that....but lets
> grasp this concept first! )
>
>
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users