문제

Am using Debian 5, Python 2.5 with cx_Oracle unicode version installed. I try to connect using the below script but its failing

>>> connection = cx_Oracle.connect('hr/XXXXX@local_xe')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: argument 1 must be unicode, not str

I think because the cx_Oracle installed is a unicode version, its asking me to specify the unicode as first parameter. but, Its not taking strings and I don't know what I could supply else?

도움이 되었습니까?

해결책 2

the solution was to place the following

cx_Oracle.connect(u'hr/XXXXX@local_xe')

a u before the string. Not sure why, but that solved the problem for me.

다른 팁

You should try

cx_Oracle.connect(u'hr/XXXXX@local_xe')

Since you have the unicode version of cx_Oracle, it expects the connection string to be a unicode sring (argument 1 must be unicode, not str)

Putting a u'' infront of a string converts it into unicode, and hence it doesn't throw the error.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top