New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoSuchColumnError: "Could not locate column in row for column" when using out parameters in postgresql #3103
Comments
Michael Bayer (@zzzeek) wrote:
this is a common error for which there can be many causes; I can't diagnose it without a test case.
I have no idea what this is referring to. Existing bugs targeted for the next possible release you can see in https://bitbucket.org/zzzeek/sqlalchemy/issues?status=new&status=open&milestone=0.9.7. Unfortunately this is not really a bug report as no actionable detail is provided. If you can get me a test case or some reference to what prior bug has been reported, that would help. Reopen when you can get this to me, thanks. |
Changes by Michael Bayer (@zzzeek):
|
Krishnakant Mane wrote: I had discussed this before on irc. Any ways, the thing is that I have a lot of stored procedures in my software. The rdbms we are using is postgresql <www.postgresql.org> When I make calls to stored procedures, I have a function called execProc, thanks to a few sqlalchemy guys who helped me write it 2 years ago. This is the function which does the calling to stored procedures and then returns the result def execproc(procname, engine, queryParams=[]): This worked very well with version upto 0.7.8. Now with latest sqlalchemy versions I.E 0.9.x I get the error Praveen had mentioned. Basically the column name is not getting recognised it seems. |
Praveen Arimbrathodiyil (@pravi) wrote: Krishnakant has provided more details and sample code for reproducing the issue. You can see the source code for gnukhata at http://www.gnukhata.org/core_engine/ |
Changes by Praveen Arimbrathodiyil (@pravi):
|
Changes by Michael Bayer (@zzzeek):
|
Michael Bayer (@zzzeek) wrote: SQLAlchemy does not have support for OUT parameters on any backend except Oracle at this time. In order to use OUT parameters now, you need to use the DBAPI function callproc(), see http://initd.org/psycopg/docs/cursor.html#cursor.callproc. your function should look like this:
|
Michael Bayer (@zzzeek) wrote: Note that there has never been support for this (OUT parameters specifically). If your function worked on 0.7 with OUT parameters, it was a cooincidence. If we continue, please do the following:
|
Krishnakant Mane wrote: here is the stored procedure Here is my rpc call in Python..
It used to work, meaning the out parameters were getting perfectly mapped in the said previous version of sqlalchemy. |
Michael Bayer (@zzzeek) wrote: Please understand that I cannot diagnose the error without actually running a program. I don't have a stored procedure with OUT parameters available to me with which to test and PG's docs are scant on how these are used, nor it is clear from psycopg2's documentation how they function, so the only way for me to know is experimentation. To that end, please provide the source code for the actual getVoucherDetails stored procedure as well as the exact arguments that are being sent to it. I have no idea what the issue is as I have never worked with PG OUT parameters, it is not any feature that was ever supported in SQLAlchemy. However, as this is not any feature I've ever implemented, I've given you a workaround, and my time is very valuable. I would ask that you please use the workaround given, thanks. |
Michael Bayer (@zzzeek) wrote: just as a reference, here's stored procedures with traditional parameters. The
|
Praveen Arimbrathodiyil (@pravi) wrote: You can install gnukhata from http://people.debian.org/~praveen/gnukhata/ and run it to reproduce the issue. The complete code is at https://gitlab.com/gnukhata/core_engine/blob/master/gnukhataserver/rpc_transaction.py |
Michael Bayer (@zzzeek) wrote: that file contains no source code for an actual stored procedure. A stored proc looks like this :http://www.postgresqltutorial.com/postgresql-create-function/ You need to provide a simple reproducing test case, it's not my job to install/debug your whole application. |
Praveen Arimbrathodiyil (@pravi) wrote:
This was already provided earlier by Krishnakant. Since you are already doing your job well, there is no point in wasting your precious time anymore. Have a good day. |
Michael Bayer (@zzzeek) wrote: Sorry, didn't see it as it wasn't formatted. trying now. |
Michael Bayer (@zzzeek) wrote: OK, here is the next test, I need:
|
Krishnakant Mane wrote: Thanks, but the code you gave did not work either. I can happyly recall that it was you who had helped me in getting this to work a couple of years back. It kept on working till date with out parameters and now nothing seems to do it. |
Michael Bayer (@zzzeek) wrote: @krishnakant_mane : "the code you gave did not work either." - which "code", the one that uses psycopg2 callproc? and "did not work", what was the full output of the program?
calling a Postgresql function is very easy. But using one with OUT parameters, I have no idea how to do that. psycopg2 should support it but I have no idea where psycopg2 places the values of these OUT parameters, unless a special value-holding object is being used in the parameters; this would be inside of "queryParams" in your function, but you have yet to show me what exact objects are being placed in this "queryParams" structure.
how do you know the version of psycopg2 is not the issue here?
Please copy the test case I have listed at https://bitbucket.org/zzzeek/sqlalchemy/issue/3103/nosuchcolumnerror-could-not-locate-column#comment-11079974, experiment with it locally, and modify it such that it reproduces your error. Do not use any additional libraries, it has to be entirely self contained so that I can run it here. It needs to run on a brand new machine that has only a blank database and psycopg2 installed. thanks. |
Praveen Arimbrathodiyil (@pravi) wrote:
Because we use the same version of psycopg2 with both versions of sqlalchemy (0.7.8 and 0.9.6) and gnukhata works with 0.7.8, but fails with 0.9.6. |
Praveen Arimbrathodiyil (@pravi) wrote: update title to mention out parameters |
Changes by Praveen Arimbrathodiyil (@pravi):
|
Changes by Michael Bayer (@zzzeek):
|
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by Praveen Arimbrathodiyil (@pravi)
File "/usr/lib/python2.7/dist-packages/gnukhataserver/rpc_reports.py", line 134, in xmlrpc_getLedger
grandTotal =float(balanceRow["total_CrBal"]) + float(balanceRow["curbal"])
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/result.py", line 332, in _key_fallback
expression._string_or_unprintable(key))
sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'total_CrBal'"
org.apache.xmlrpc.XmlRpcException: error
I'm packaging gnukhata (gnukhata.org) for debian and hit this error. Krishnakant Mane (core developer of gnukhata) said everything is working fine with sqlalchemy 0.7.x. Debian sid has sqlalchemy 0.9.6. He also mentioned you have promised this would be fixed in the next release. Hopefully we can get a patch sooner so it debian and ubuntu packages can be updated. Currently we are forced to create a different repository and ship 0.7.x version of sqlalchemy.
The text was updated successfully, but these errors were encountered: