Pergunta

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?

Foi útil?

Solução 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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top