I have a mysql table with LONGBLOB datatype as one of the columns. I wanted to insert PDF into that column. I have tried this.
file = open(r'path to file\myfile.pdf', 'rb').read()
id='2'
q1 = QSqlQuery("INSERT INTO table_1 (id_val,pdf_name) VALUES (%s,%s)"%(id,file))
This code is not inserting id_val and PDF into table and its not showing any error. Then i split the code.
file = open(r'path to file\myfile.pdf', 'rb').read()
id='2'
q1 = QSqlQuery("INSERT INTO table_1 (id_val) VALUES (%s)"%(id))
q2 = QSqlQuery("UPDATE table_1 SET pdf_name=%s WHERE id_val='2'"%(file))
This code inserts the id_val into table but doesnt update the BLOB pdf.
Can someone help in this?