What if I don't have access to session? I receive obj (mapped SQLA
class instance) as an argument to a method.
What I actually would like to do is add a method to the class that does
the raw query like so:
class MyClass(object):
def __init__(self, arg1, arg2):
self.arg1 = arg1
self.arg2 = arg2
@property
def fetchOutsideAtts(self):
con = getConnection(self) # How do I do this.
con.execute(select fields from table where id = ?)
...
return atts
Is it possible to do this?
Randall
Michael Bayer wrote:
> the connection is returned relative to the mapper given, since there
> can be more than one engine in use:
>
> conn = session.connection(<mapper>)
>
> although if the Session is bound to an engine which you want to use,
> which is probably what you want, then you can just say:
>
> conn = session.connection(None)
>
> I may make the argument optional soon, so it would just be
> session.connection().
>
> then with the connection you can just execute things:
>
> result = conn.execute(sometable.select(), **params)
-------------------------------------------------------------------------
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