Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
9359 มุมมอง

Hi everybody,

I would like to know if it possible to concert bytea picture into binary. I take the bytea into a field of the database and i want to "put" it into a binary field like this:

cr.execute('SELECT res_company.logo_web FROM res_company') res = cr.fetchall() v['logo_Print'] =base64.decodestring(str(res[0]))

But doesn't work.

Someone have some idea, please? How is possible to concert my "tuple" into a string and after binary?

Thanks a lot!

Selverine

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

cr.fetchall() returns an array of arrays. If you cant to access the first column (logo_web) of the first row (I assume that there is only one row/company), then you have to use res[0][0].

อวตาร
ละทิ้ง
ผู้เขียน

Hi Andreas, Thank you for your help. It works!

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
มี.ค. 15
21339
0
ก.ย. 18
2713
1
พ.ย. 24
998
2
เม.ย. 23
2909
1
ธ.ค. 22
5282