Topic: BLOB python3 fdb

Misters, such problem:
There is a basis, in it photos of users are stored in one of labels
The code I write on a python, but I think problems here should not be

import fdb
con = fdb.connect (
host ='localhost ', database ='C:\db.gdb ';
user ='sysdba ', password ='masterkey'
cur = con.cursor ()
SQL = "select * from photos_big"
cur.execute (SQL)
for (cli_n, photo) in cur:
if cli_n == 10:
filename = ' C: \\' +str (cli_n) + ' _big.jpg'
f2 = open (filename, ' wb ')
f2.write (photo)
f2.close ()
con.commit ()
cur.close ()
con.close ()

This code works on hurrah.
And here is how to write down in basis I do not understand (((
I interpose a piece of formation of request.

f2 = open (filename167n, ' rb ')
photo = f2.read ()
f2.close ()
SQL = "insert into PHOTOS (CLI_N, PHOTO) Values ((%s, %s)" % (' 3 ', photo)
cur.execute (SQL)

And the error takes off for the moment cur.execute (SQL).
I certainly understand what to push in such type the binary data not the best variant and consequently probably it and does not work
Prompt  how to write down BLOB in the field
In advance many thanks to all who responds


Re: BLOB python3 fdb

And so?

f2 = open (filename167n, ' rb ')
SQL = "insert into PHOTOS (CLI_N, PHOTO) Values (??)"
cur.execute (SQL, (3, f2))
# And to close all it is finite

Here https://www.firebirdsql.org/file/docume … statements told


You may pass BLOB values as open file-like objects, and FDB will handle the transfer of BLOB value.