I use Python 3.5 for this task + library fdb. My script:
import fdb
con = fdb.connect(
host='host', database='database',
user='IAKUZNETSOV', password='111111'
)
cur = con.cursor()
cur.execute("select DATA from ATTACHMENTS where OID = '6512165313'")
fileToSave= cur.fetchone()[0]
with open('c:\\python5.jpg', 'wb') as f:
f.write(fileToSave)
After attempts to save the file I receive error:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 578: character maps to <undefined>
Encoding fields in the database: Win-1251 type: Blob.
How can I fix it?