[sqlalchemy] Using SQLAlchemy to call stored procedures

214 views
Skip to first unread message

Mark

unread,
Apr 24, 2010, 1:38:52 PM4/24/10
to sqlalchemy
Hi everyone,

I'm currently trying to convert an existing Zope web application over
to Pylons. My DBA created a whole bunch of stored procedures for the
web application that I would really love to use in my Pylons project.
Some of the stored procedures takes a "cursor" as an argument. I'm
not very DB savvy, so please forgive me if whatever I mentioned above
doesn't sound right to you.

My Question is:

Supposing I have a stored procedure in my Oracle DB called
"retrieveList", how do I call that stored procedure to return me a
result set in SQLAlchemy??

I know how to do it in the normal ORM way, like:

session.query(Employee).filter(Employee.something == something).all()

Could you please teach me what to import as well? What are the
necessary modules required for calling stored procedures in
SQLAlchemy?

Thanks a million guys!

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

David Gardner

unread,
Apr 27, 2010, 12:15:11 PM4/27/10
to sqlal...@googlegroups.com
Not sure about Oracle, but you should be able to do something like:

from sqlalchemy import func
session.query(Employee).filter(Employee.something.in_(func.retrieveList()).all()

Not sure about how to get the cursor object.



On 04/24/2010 10:38 AM, Mark wrote:
> Hi everyone,
>
> I'm currently trying to convert an existing Zope web application over
> to Pylons. My DBA created a whole bunch of stored procedures for the
> web application that I would really love to use in my Pylons project.
> Some of the stored procedures takes a "cursor" as an argument. I'm
> not very DB savvy, so please forgive me if whatever I mentioned above
> doesn't sound right to you.
>
> My Question is:
>
> Supposing I have a stored procedure in my Oracle DB called
> "retrieveList", how do I call that stored procedure to return me a
> result set in SQLAlchemy??
>
> I know how to do it in the normal ORM way, like:
>
> session.query(Employee).filter(Employee.something == something).all()
>
> Could you please teach me what to import as well? What are the
> necessary modules required for calling stored procedures in
> SQLAlchemy?
>
> Thanks a million guys!
>
>


--
David Gardner
Pipeline Tools Programmer
Jim Henson Creature Shop
dgar...@creatureshop.com
Reply all
Reply to author
Forward
0 new messages