You use the "func" construct to invoke a function.  This can be passed to an 
execute() method directly where it should embed itself into a SELECT:

        from sqlalchemy import func

        result = engine.execute(func.name_of_my_pg_function(1, 2, 3))

Manipulation of cursors is not supported by SQLAlchemy beyond calling the basic 
fetchone()/fetchmany()/fetchall() methods of DBAPI.   If you need non-standard 
cursor control methods like "scroll()",  you can no longer use engine.execute() 
and need to use psycopg2 cursors directly:

        http://initd.org/psycopg/docs/cursor.html

To get at a psycopg2 cursor from a SQLAlchemy engine:

        connection = engine.raw_connection()
        cursor = connection.cursor()

Usage is then that described at http://initd.org/psycopg/docs/cursor.html

        cursor.execute("SELECT my_pg_function(%(param1)s, %(param2)s, 
%(param3)s)", {'param1':1, 'param2':2, 'param3':3})

hope this helps !





On Sep 11, 2011, at 1:48 PM, Krishnakant Mane wrote:

> I think the subject line makes it pritty clear.
> I want to know how i can use the expression api to make calls to postgresql 
> stored procedures written in plpgsql.
> For example how to pass input parameters and how to manipulate cursor objects 
> etc.
> happy hacking.
> Krishnakant.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to