I have googled and searched this site, but nothing specific appears and cannot get this working. Here is the code:
binData = ''.join(map(lambda x: chr(x % 256), attach.attcoll))
sql_stmt = """INSERT INTO attachments (attno,filename,fileextension,projNo,procNo,wpattachment) \
VALUES ('%s','%s','%s','%s','%s','%s') ON DUPLICATE KEY UPDATE filename='%s',fileextension='%s'""", attach.attno,\
attach.filename,attach.fileextension,attach.projNo,attach.procNo,binData,attach.filename,attach.fileextension
try:
cursor.execute(MySQLdb.escape_string(sql_stmt))
conn.commit()
The attach.attcoll is data that comes in over JSON from an SQLite blob and java code on the client side. I then want to write binData to MySQL with MySQLdb, but keep getting a TypeError, and a return code of 500. Any ideas on how to fix this. I want to store binData into a MySQL blob.