this has to do with the DBAPI allowing it. It’s often possible but you need
to do it in such a way that the DBAPI lets it pass through.
I’d start by experimenting with a DBAPI cursor, suppose this is pyodbc (I’m not
sure that this is, but this seems like SQL server)
import pyodbc
conn = pyodbc.connect(user=‘u’, password=’t’, dsn=‘mydsn’)
cursor = conn.cursor()
cursor.execute("set @temp=0;select (@temp:= @temp + 1) as ranking, userid from
mytable;”)
print cursor.fetchall()
Alternatively, you can get at a cursor from SQLAlchemy using the instructions
at
http://docs.sqlalchemy.org/en/rel_0_9/core/connections.html#working-with-raw-dbapi-connections
<http://docs.sqlalchemy.org/en/rel_0_9/core/connections.html#working-with-raw-dbapi-connections>.
if you can get a DBAPI cursor working, then that’s what you’d do with
SQLAlchemy execute() also. if that doesn’t work, then you can post here what
the cursor can do that SQLAlchemy can’t.
> On Dec 10, 2014, at 10:04 AM, shusheng liu <[email protected]> wrote:
>
> Hello, all. I want to execute an sql with temp variables in sqlalchemy just
> like in mysql.
> Here is my sql clause:
> set @temp=0;select (@temp:= @temp + 1) as ranking, userid from mytable;
> But sqlalchemy tells "This result object does not return rows. "
> Who can tell me if I made some mistakes, or this is not supported by
> sqlalchemy yet?
> Thank you.
>
> --
> 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 [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/sqlalchemy
> <http://groups.google.com/group/sqlalchemy>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.