2 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: howto map python-cla...
FromSent OnAttachments
peter29 Jul 2007 06:21 
Michael Bayer29 Jul 2007 07:06 
Subject:[sqlalchemy] Re: howto map python-class and stored procedures
From:Michael Bayer (mike@zzzcomputing.com)
Date:07/29/2007 07:06:28 AM
List:com.googlegroups.sqlalchemy

On Jul 29, 2007, at 9:21 AM, peter wrote:

Hello,

recently i started working with SQLAlchemy and i have one question regarding the stored procedures. On the following website, there is a quide of how to execute the stored procedures: http://groups.google.com/group/sqlalchemy/browse_thread/thread/ d0b3ad0379606e81/eb1447a0fd3129cc?lnk=gst&q=func+graph&rnum=1 My question is how to map Python-class and stored procedures. For exapmple:

class Person: givenName surName id

and the procedures: getPerson( id ) setPerson( id, gName, sName ) createPerson( ) removePerson( id )

Can you please tell me if it is possible to use getPerson instead of select...; and setPerson... instead of update?

the ORM was designed around a model of issuing direct SQL. if you have stored procedures that do persistence, then your "ORM" is partially embedded in your database. Its may be possible to get your "getPerson" function to work for ORM selects, by creating a select statement out of it and mapping to that (but that would require a getPerson() that returns lists of "person" rows). but for the update side, SA's ORM only knows INSERT/UPDATE/DELETE. youd have to issue those setPerson/createPerson statements using contstructed or textual SQL statements.