[python-win32] adodbapi: using prepared statements
Alan Trick
atrick at tri-tech.com
Fri May 25 17:47:35 CEST 2012
I'm trying to use prepared statements with the adodbapi module, but
it's not working. I'm using the Visual FoxPro OLE DB drivers, and I'm
worried that this is just something that they can't handle.
Here's some sample code:
---
import adodbapi
conn = adodbapi.connect('Provider=vfpoledb;Data
Source=C:\ClinEsse\Data\Frost_7_12\medimax.dbc;Collating
Sequence=machine')
cur = conn.cursor()
cur.execute("select * from chiro1 where prefix= 'LEG' ")
print [`c` for c in cur.fetchall()]
cur.execute("select * from chiro1 where prefix = ?", ['LEG'])
print [`c` for c in cur.fetchall()]
---
The first "execute" call returns a list of SQLrows, and works fine,
but the second execute call (the prepared statement) raises the
following exception.
Traceback (most recent call last):
File "test.py", line 9, in <module>
cur.execute("select * from chiro1 where prefix = ?", ['LEG'])
File "C:\Python27\lib\site-packages\adodbapi\adodbapi.py", line
1006, in execute
self._buildADOparameterList(operation,parameters)
File "C:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 963,
in _buildADOparameterList
p=getIndexedValue(self.cmd.Parameters,i)
File "C:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 77,
in getIndexedValue
return obj(index)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py",
line 186, in __call__
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
u'ADODB.Parameters', u'Item cannot be found in the collection
corresponding to the
requested name or ordinal.', u'C:\\Windows\\HELP\\ADO270.CHM',
1240649, -2146825023), None)
I've tried using different paramstyles but the all give the same result.
More information about the python-win32
mailing list