Getting binary data out of a postgre database

Diez B. Roggisch deets at web.de
Mon Jun 27 17:12:44 EDT 2005


projecktzero wrote:
> Sorry for the late reply. I didn't check the group/list over the
> weekend.
> 
> Anyway, I added a print rec[0] just after the fetchone. Then I ran it
> from the command line, and it spewed a bunch of binary gibberish nearly
> locking up Putty.
> 
> To me, it seems like it's coming out in the right format, but I'm not
> sure what I'm doing wrong.  If you have any ideas, I'd really
> appreciate it.

What does

print rec[0].__class__

give you?

And what about using

tempFile.write(str(rec[0]))

if print really resulted in the binary data, this might help.

The DB-Api isn't too detailed about binary columns at all - the just 
mentioned a Binary() object, and something about buffer objects. I'm not 
sure how to ndeal with these - they seem to be mentioned in the 
C-Api-Section only.


Sorry that I can't be of more help.
Diez



More information about the Python-list mailing list