On Wed, 14 May 2014 07:54:58 -0700 (PDT)
"J. D." <
john.arno...@gmail.com> wrote:
> Can someone help me with cx_Oracle and Django?! :)
>
> I have Oracle DB 11.2 with many PLSQL-procedures in it that return cursor
> with various output. I want to work with them without django ORM and
> directly call them.
>
> First of all i ran my python code without django, with the cx_Oracle driver
> and everything works well.
>
> conn = cx_Oracle.connect('user', 'pass')
> ora_cur = conn.cursor()
> l_cur = ora_cur.var(cx_Oracle.CURSOR)
> l_query = ora_cur.callproc('user.VIEW.procedure_with_cursor', (None, None,
> None, None, l_cur,)) #None - "*in*" parameters and l_cur - *out *
> l_query[0].fetchall()
>
>
> but with the django and same code, i got the error:
>
> import cx_Oracle
> from django.db import connection
>
> ora_cur = connection.cursor()
> ora_cur.execute("SELECT * from v$version") #it works
>
> l_cur = ora_cur.var(cx_Oracle.CURSOR) #-> *Error: *Variable_TypeByPythonType():
> unhandled data type
> l_query = ora_cur.callproc('user.VIEW.procedure_with_cursor', (None, None,
> None, None, l_cur,))
> l_query[0].fetchall()
>
>
> Django Version: 1.6.4 Exception Type: NotSupportedError Exception Value:
>
> Variable_TypeByPythonType(): unhandled data type
>
>
>
> Python Version: 2.7.3cx_Oracle 5.1.2
>
You're seeing that error because cursor returned from Django connection is not
actually cx_Oracle cursor but a wrapper that has similar methods. That is done to
overcome different binding variable types and to use %s (oracle uses :name format)
You should be able to get pure cx_Oracle cursor by calling:
connection._cursor()
--
Jani Tiainen