cursor.callproc with oracle backend does not work
When using cx_oracle standalone, in order to call stored procedures, it is possible to call them using callproc(), which does some jobs including using bind variables for you. However, in django's FormatStylePlaceholderCursor wrapper class, there is no callproc(). That means that calling callproc() as a member of a FormatStylePlaceholderCursor cursor will call the original cx_oracle callproc(). This in turn uses django's execute(). It is probably expecting the behaviour of the original execute.
In this case the query is however not to be changed. Maybe a solution is to add a callproc function to the wrapper class and let it duplicate cx_oracle's callproc so it works with djangos parameters.
The error raised is:
File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py" in execute
483. query = smart_str(query, self.charset) % tuple(args)
TypeError at /test/ora_django/
not all arguments converted during string formatting
Attachments
(1)
- base.py.diff
(6.7 KB
) - added by hklv 16 years ago.
- Patch for Django-1.0/django/db/backends/oracle/base.py. Adds support for Oracle stored procedures and functions ("callproc" and "callfunc" method ). Added a "commit" method. Fixed a typo in the _format_params method.
Download all attachments as:
.zip
Change History
(8)
Triage Stage: |
Unreviewed → Design decision needed
|
Cc: |
ian.g.kelly@… added
|
Keywords: |
Oracle added
|
Owner: |
changed from nobody to Matt Boersma
|
Status: |
new → assigned
|
Keywords: |
cursor callproc added
|
Triage Stage: |
Design decision needed → Accepted
|
Cc: |
Erin Kelly added; ian.g.kelly@… removed
|
Has patch: |
set
|
Needs tests: |
set
|
Patch needs improvement: |
set
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
cx_Oracle's callproc is written in C and might not be straightforward to reproduce in Python, code duplication issues aside. I suggest we have the execute (and executemany?) method inspect the query to determine the style of placeholder used. This could be as simple as throwing a try..except around the query reformatting.