Encoding problems with DCOracle2

T

Timo Virkkala

I'm having some trouble with Python2.2 and DCOracle2. I'm successfully
executing a query, and getting the result I'm hoping for - with an added
bonus of some interesting encoding. The beginning of the result set I
get looks like this:

[['\x00A\x001', '\x00M\x00i\x00k\x00e\x00
\x00P\x00o\x00r\x00t\x00n\x00o\x00y', None, None,
'\x00d\x00r\x00u\x00m\x00s'], ...

So, where are those \x00 -characters coming? It should read:

[['A1', 'Mike Portnoy', None, None, 'drums'], ...

(...it's an artist database, and that's Dream Theater's drummer..)
 
P

Peter Otten

Timo said:
I'm having some trouble with Python2.2 and DCOracle2. I'm successfully
executing a query, and getting the result I'm hoping for - with an added
bonus of some interesting encoding. The beginning of the result set I
get looks like this:

[['\x00A\x001', '\x00M\x00i\x00k\x00e\x00
\x00P\x00o\x00r\x00t\x00n\x00o\x00y', None, None,
'\x00d\x00r\x00u\x00m\x00s'], ...

So, where are those \x00 -characters coming? It should read:

[['A1', 'Mike Portnoy', None, None, 'drums'], ...

(...it's an artist database, and that's Dream Theater's drummer..)

Seems you are getting unicode from the db. Here's how to convert it to
latin1:
'utf-16-be').encode('latin1')
'Portnoy'

Peter
 
T

Timo Virkkala

Peter said:
Timo said:
I'm having some trouble with Python2.2 and DCOracle2. I'm successfully
executing a query, and getting the result I'm hoping for - with an added
bonus of some interesting encoding. The beginning of the result set I
get looks like this:

[['\x00A\x001', '\x00M\x00i\x00k\x00e\x00
\x00P\x00o\x00r\x00t\x00n\x00o\x00y', None, None,
'\x00d\x00r\x00u\x00m\x00s'], ...

Seems you are getting unicode from the db. Here's how to convert it to
latin1:
'Portnoy'

Thanks, that solved it! Now, it feels like I'm treating a symptom here,
not the cause. Is there a way to set the database (Oracle 9i) to send me
something else than Unicode?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top