Environment:
Sybase/ODBC/Windows/Python2.5

I have been given a legacy database, and need to read the binaryfiles out to a 
disk.  The table has columns "filename" and "binaryFile", where the binaryFile 
is a BLOB

My python script so far is:

import pyodbc
cnxn=pyodbc.Connection("DSN=sybasedatabase")
cursor=cnxn.cursor()

p=cursor.execute("select top 1 * from FOO..Table").fetchone()

#p contains ('UsersOldFile.rtf', <read-only buffer for 0x010E1540, size 1496, 
offset 0 at 0x010C04E0>)

#I tried to write this out to the disk as:
myfile=open(p[0],'wb')
myfile.write(p[1])
myfile.close()

#but all I get is gibberish.  Is there another way to handle the buffer, or 
something else I'm missing?


      
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to