[Tutor] problem with simple sqlite script
Kent Johnson
kent37 at tds.net
Fri Nov 7 12:48:13 CET 2008
On Fri, Nov 7, 2008 at 3:49 AM, aivars <aivars868 at gmail.com> wrote:
> import sqlite3
>
> sPath=r'e:\pythonexamples\aivars2.db'
>
> con=sqlite3.connect(sPath)
> cur=con.cursor()
> cur.execute("insert into test (name) values (?)",sPath)
The second argument to execute() is a *sequence* of parameter values.
A string is a sequence of characters, so by passing a plain string you
are saying that each character of the string is a parameter to the
SQL.
Try adding braces around the parameter to make list:
cur.execute("insert into test (name) values (?)", [sPath])
Kent
More information about the Tutor
mailing list