I've played with this a bit and I think there must be a bug in pypyodbc that make it not behave as the documentation suggests:
In most cases, you can simply try pypyodbc in your existing pyodbc powered script with the following changes
For example, I ran this code with pyodbc
and everything works fine:
... import pyodbc as db
... conn = db.connect(connect_string)
... cursor = conn.cursor()
>>> # One parameter
... res = cursor.execute("SELECT 1 WHERE 1=?", [1,])
... print(cursor.fetchall())
[(1, )]
>>> # Two parameters
... res = cursor.execute("SELECT 2 WHERE ?=?", [1, 1])
... print(cursor.fetchall())
[(2, )]
>>> conn.close()
But switching the import line to pypyodbc
breaks the second example:
... import pypyodbc as db
... conn = db.connect(connect_string)
... cursor = conn.cursor()
>>> # One parameter
... res = cursor.execute("SELECT 1 WHERE 1=?", [1,])
... print(cursor.fetchall())
[(1,)]
>>> # Two parameters
... res = cursor.execute("SELECT 2 WHERE ?=?", [1, 1])
... print(cursor.fetchall())
Traceback (most recent call last):
...
TypeError: 'DatabaseError' object does not support indexing
>>> conn.close()
So I don't think this is anything you're doing wrong; either pypyodbc is broken for this use case or its documentation is wrong. If I can figure out which I'll file a bug.