Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

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")
share|improve this question
    
What have you tried? Where is the code you have which can demonstrate the problem? "Dear diary" type questions are not very helpful. – tadman Nov 4 '14 at 17:25
    
Added some more information... – MichaelJohn Nov 6 '14 at 17:04
    
That query looks incomplete. Are you sure that's the entire query? Why no closing bracket on your VALUES(...)? – tadman Nov 6 '14 at 17:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.