1

For some reason I keep getting an error when trying to run the code below:

pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented (106) (SQLBindParameter)')

I've used pyodbc many times and have never had this problem before. I have tried this query without params by including the parameters in the sql string explicitly and I have the same problem. I am using Python 3.3 and am connected to a MS Access .mdb file.

record = ('1AC401', 'CAB 1', 'OTSG 1 ROOM', 5, 8, 'CD14-PT-05', 'WFB FDWTR WARMING')

cabling_id = '1AC401/CAB 1/OTSG 1 ROOM'

sql = 'UPDATE [CIOC_DATA] SET [charm_enabled] = ?, ' \
      '[device_tag] = ?, ' \
      '[charm_description] = ?, ' \
      '[charm_cabling_id] = ?, ' \
      'WHERE [charm_baseplate] = ? ' \
      'AND [charm_Address] = ?'
params = ("T", record[5], record[6], cabling_id, record[3], record[4])
cursor.execute(sql, params)
cursor.commit()

Update - I have added the traceback:

Traceback (most recent call last):
  File "C:\Users\*****\Documents\Projects\******_******** *** Upgrade\NoEvernote\populateBulkEdit.py", line 48, in <module>
    cursor.execute(sql, params)
pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented  (106) (SQLBindParameter)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\******\Documents\Projects\******_******** *** Upgrade\NoEvernote\populateBulkEdit.py", line 52, in <module>
    + ': ' + e.args + '\n' )
TypeError: Can't convert 'tuple' object to str implicitly

Update 2

The TypeError has nothing to do with the underlying problem. It was a secondary mistake with my error handling code. Pay attention only to the pyodbc.Error in the code excerpt above.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
jaromey
  • 666
  • 2
  • 10
  • 27
  • show us a `record` and a `cabling_id` – deinonychusaur Feb 21 '14 at 13:08
  • record: ('1AC401', 'CAB 1', 'OTSG 1 ROOM', 5, 8, 'CD14-PT-05', 'WFB FDWTR WARMING'); cabling_id: '1AC401/CAB 1/OTSG 1 ROOM' – jaromey Feb 21 '14 at 14:09
  • 1
    What happens when you remove the comma after [charm_cabling_id] = ?, I would think access would be expecting another field assignment. – Jimmy Smith Feb 21 '14 at 16:17
  • That was a good catch Jimmy. I corrected it, however, I am still receiving the same error. – jaromey Feb 21 '14 at 17:05
  • 1
    By the way, the solution for the same problem in the question cited immediately above was to use [pypyodbc](https://code.google.com/p/pypyodbc/) instead of pyodbc. – Gord Thompson Feb 21 '14 at 18:52
  • Thank you so much Gord. I installed the pypyodbc package and edited my code by simply changing pyodbc to pypyodbc and voila! I guess I should use pypyodbc from now on instead of pyodbc? – jaromey Feb 23 '14 at 03:42

1 Answers1

1

I'd guess that one of these params you are passing is a tuple and not a String. Maybe the address.

lucasnadalutti
  • 5,818
  • 1
  • 28
  • 48
  • The variable 'record' is a tuple but I am using an index to pass in only the individual values contained within it which are all either strings or integers. – jaromey Feb 21 '14 at 13:23
  • And I just tried again by explicitly converting record to a list and I get the same error. None of the elements in the sequence are a tuple. – jaromey Feb 21 '14 at 13:28
  • 1
    Hmm in that case, it's a really odd issue. I would try removing some params from the query until I'd found which is the one causing this error. – lucasnadalutti Feb 21 '14 at 13:31