How exactly can I get a connection in such manner?
Here's what I tried:
from turbogears.database import session
...
conn = session.context.connection(User)
conn.execute("<my statement>")
And here's what I got:
AttributeError: 'SessionContext' object has no attribute 'connection'
According to the "doc" a class SessionContext really neither has
'connection'
attribute nor any method dealing with a connection.
On Jun 13, 11:39 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jun 13, 2007, at 11:21 AM, kwarg wrote:
>
>
>
>
>
>
>
> > I defined a model with several DB mapped entities. Here's one of them:
> > ...
> > address_table = Table("address", metadata, autoload = True)
> > ...
> > class Address(object):
> > pass
> > ...
> > assign_mapper(session.context, Address, address_table)
>
> > Then in the controller an instance of Address class is modified ans
> > saved:
> > # 1. construct/read object
> > a = Address.get(address_id)
> > ...
> > # 2. modification of object a properties
> > ...
> > # 3. save changes
> > a.save()
> > a.flush()
> > All of 1., 2. and 3. use the same connection for interaction with the
> > DB.
> > I need to run my custom query in that connection before 3. executes.
> > How can I get that connection?
> > Thank you.
>
> how are you creating the transaction ? if via Connection, you have
> it. if via SessionTransaction, trans.connection(Address).execute
> (<your statement>), or alternatively session.context.connection
> (Address).execute(<your statement>).- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---