0

I am accessing a MySQL database (V5.5) via a Python program for generating bespoke reports. The standard fields (int, varchar, datetime, etc.) present no problem - in general I am putting these into Python lists for subsequent processing. However one table makes extensive use of BLObs; these hold either Binary/HTML/PDF/PNG/CSV data. My problem is how to handle them once they are returned in a SELECT statement. The Binary data needs further processing and the PNG may need to be inserted into a report.

Thanks in advance...

I have tried various things including code based on:- How to insert / retrieve a file stored as a BLOB in a MySQL db using python

Te relevant snippets are:-

TheData = open("/home/mjh/Documents/DemoData/sjp.bin", 'rb').read()

sql = "Insert into Results (idResults, idClient, TestDateTime, ResultBinary) \
    Values (10, 7, '2014-11-05 14:09:11', %s"

cursor.execute(sql, (TheData,))

This comes back with:-

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near '' at line 1")
3
  • What have you tried? Where is the code you have which can demonstrate the problem? "Dear diary" type questions are not very helpful. Commented Nov 4, 2014 at 17:25
  • Added some more information... Commented Nov 6, 2014 at 17:04
  • 1
    That query looks incomplete. Are you sure that's the entire query? Why no closing bracket on your VALUES(...)? Commented Nov 6, 2014 at 17:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.