[Tutor] problem with simple sqlite script

aivars aivars868 at gmail.com
Fri Nov 7 09:49:59 CET 2008


Hello,
I am getting frustrated.

I have been successfully inserting, deleting, etc records with python
and sqlite no problem.

Suddenly the following very simple scrip does not work:

import sqlite3

sPath=r'e:\pythonexamples\aivars2.db'

con=sqlite3.connect(sPath)
cur=con.cursor()
cur.execute("insert into test (name) values (?)",sPath)
con.commit()

here is an error message

Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 307, in RunScript
    debugger.run(codeObject, __main__.__dict__, start_stepping=0)
  File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\__init__.py",
line 60, in run
    _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py",
line 631, in run
    exec cmd in globals, locals
  File "E:\PythonExamples\test.py", line 7, in <module>
    cur.execute("insert into test (name) values (?)",sPath)
ProgrammingError: Incorrect number of bindings supplied. The current
statement uses 1, and there are 28 supplied.

What the hell is going on? I have used the syntax with (?) successfully before!

I tested and found out that above script allows me to insert only
single character into database. Then it works.

Using ActiveState python 2.5, WinXP

Thanks for any hint.

Aivars


More information about the Tutor mailing list