On 11/02/12 21:10, Michael Bayer wrote:
def execproc(procname, engine, queryParams=[]):
function = getattr(func, procname)
function_with_params = function(*queryParams)
return
engine.execute(function_with_params.execution_options(autocommit=True))
Hi Michael,
I tryed this code with postgresql (psycopg2 ).
I have a group table with the fields.
groupcode integer, groupname text and groupdesc text.
When I pass in a procedure name called get groups with all the above
listed columns as output parameters (actually the procedure returns
setof rows), I get the could not locate column on the groupcode field.
I had previously mailed you with a longish function called execProc
which you corrected and maild back.
With that long function without func, I never had this problem.
could you please point out what could have gone wrong?
Note that I am not paisting the function here as it is exactly the same
as you had provided.
I will however paist the line which gave me the error.
I will infact give you the code concerning the function where your
version of execProc was called.
#note that we have a dbconnect module containing an array of engines and
also the execProc method.
res = dbconnect.execproc("getAllGroups",dbconnect.engines[client_id])
#since we know that the function getAllGroups exists and that it returns
the exact 3 fields from the groups table,
#we are shure we have some records to process.
#We will loop through the generated resultset in res
#We wish to make a 2 dymentional list of rows and columns to be
transfered over an xmlrpc connection.
result = []
for row in res:
result.append([row["groupcode"],row["groupname"],row["groupdesc"]])
return result
I know for sure that the names of the fields used inside row[] are
absolutely correct, and the code actually works when I use the old
execProc which did not have all the sqlalchemy's func trickery.
Could you please explain?
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.