Postgres BYTEA problems

S

Steve

I've searched throughout the python website and can't find an answer.

My problem:
After getting a BYTEA from a postgres database using Pygresql call:
Code:
x = Db.query("SELECT seq FROM sequence \
              WHERE version = \'NT_004350.16\' \
              AND startloc = 1 \
              AND endloc = 1120")
y = x.getresult()[0][1]
'y' ends up containing a string of characters. THe problem is that
many of these characters should be escaped characters. However,
somewhere in the process the escape character itself is interpreted as
a character that must be escaped.
so if I should be getting
"\x00\x01"
I'll get
"\\x00\\x01"

My Thoughts:
1) Is there a way to somehow get a 'raw' uninterpreted input to the
string?
2) Can I possibly get the BYTEA results back as one very long Long?
3) I can just accept that this is the way I'm going to get my results
and try to convert the the string into something more usable.
-Any ideas how I might go about doing this?

Thanks for any help you can provide.

--Steve
 
I

Ivan Voras

Steve said:
a character that must be escaped.
so if I should be getting
"\x00\x01"
I'll get
"\\x00\\x01"

Are you sure that it's the dbapi driver that is doing it, or maybe the
data was written to the database in that way (e.g. not chr(00)+chr(01)
but '\' 'x' '0' '0' ...)?
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top