Re: incorrect binding errors.
Martin Jenkins <pysqlite-Vfh7fEhEWOlaa/[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Organization | XQP Ltd |
| Message-ID | <[email protected]> |
Eric S. Johansson wrote:
> Traceback (most recent call last):
> File "db_utils.py", line 340, in ?
> main2()
> File "db_utils.py", line 337, in main2
> res = ts.convert('[email protected]')
> File "db_utils.py", line 181, in convert
> candidates = self.cursor.execute("select * from external_internal
> where (external_ID='?') ;",external_ID)
> pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings
> supplied. The current statement uses 0, and there are 15 supplied.
This "Incorrect number of bindings" error is emitted when because you've
supplied the arguments as a string rather than as a tuple containing a
string.
> candidates = self.cursor.execute("select * from external_internal
> where (external_ID='?') ;",external_ID)
is searching for an external_ID of """?""", not binding the parameter.
The string has 15 characters but because you've quoted the question mark
the statement is expecting no parameters.
The line should be:
> candidates = self.cursor.execute("select * from external_internal
> where (external_ID=?) ;", (external_ID,))
The last bit is a tuple *containing* one string. Note the comma after
external_ID to force it to be a tuple - (external_ID) will not work.
HTH
Martin