why does cx_oracle execute() not like my string now?
Posted
by Frank Stallone
on Stack Overflow
See other posts from Stack Overflow
or by Frank Stallone
Published on 2010-05-25T09:40:16Z
Indexed on
2010/05/25
16:41 UTC
Read the original article
Hit count: 247
I've downloaded cx_oracle some time ago and wrote a script to convert data to XML. I've had to reisntall my OS and grabbed the latest version of cx_Oracle (5.0.3) and all of the sudden my code is broken.
The first thing was that cx_Oracle.connect wanted unicode rather string for the username and password, that was very easy to fix. But now it keeps failing on the cursor.execute and tells me my string is not a string even when type() tells me it is a string.
Here is a test script I initally used ages ago and worked fine on my old version but does not work on cx_Oracle now.
import cx_Oracle
ip = 'url.to.oracle'
port = 1521
SID = 'mysid'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
connection = cx_Oracle.connect(u'name', u'pass', dsn_tns)
cursor = connection.cursor()
cursor.arraysize = 50
sql = "select isbn, title_code from core_isbn where rownum<=20"
print type(sql)
cursor.execute(sql)
for isbn, title_code in cursor.fetchall():
print "Values from DB:", isbn, title_code
cursor.close()
connection.close()
When I run that I get:
Traceback (most recent call last): File "C:\NetBeansProjects\Python\src\db_temp.py", line 48, in cursor.execute(sql) TypeError: expecting None or a string
Does anyone know what I may be doing wrong?
© Stack Overflow or respective owner