Search code examples
pythonodbcfilemakerpyodbcunixodbc

unable insert jpeg into filemaker db with pyodbc : HY011 ODBC Error


I get this odbc error by trying to insert a JPEG into a FileMaker 14 database. When i run the same script against a MySQL for inserting a blob, there's no error. Inserting a text field does not produce an error. Also i have no clue and cannot find a meaningful explanation for odbc error HY011...

Can anyone help please? Thanks in advance!

The output when i type the code interactively :

Python 2.7.9 (default, Dec 13 2014, 15:13:49) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin Type "help", "copyright", "credits" or "license" for more information.

>>> import pyodbc
>>> with open('Femke.jpg', 'rb') as f:
...  data = f.read()
... 
>>> conn = pyodbc.connect('DRIVER={/Library/ODBC/FileMaker ODBC.bundle/Contents/MacOS/fmodbc.so};SERVER=localhost;DATABASE=testContainer;UID=Admin')
>>> cur = conn.cursor()
>>> cur.execute("insert into testContainer (cont) values (PutAs(?, 'JPEG'))", pyodbc.Binary(data))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('HY011', '[HY011] [unixODBC][Driver Manager]Attribute cannot be set now (0) (SQLPutData)')
>>> 

Solution

  • In the filemaker jdbc/odbc guide it clearly states that it is able to treat clob types by JDBC (page 33). For ODBC i could not find this in the document, so i suppose this is a FileMaker ODBC interface shortcoming. I now use JDBC and it works.