You need to import pysqlite, not sqlite. I think the latter has been deprecated - it's certainly quite old. AIUI pysqlite is built in to Python 2.5 so you'd import sqlite3 there.

PythonWin 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information.
>>> from pysqlite2 import dbapi2 as sqlite
>>> sqlite.version         # pysqlite wrapper version
'2.2.1'
>>> sqlite.sqlite_version  # wrapped sqlite lib version
'3.3.5'
>>> c=sqlite.connect("fred")
>>> cur = c.cursor()
>>> cur.execute("CREATE TABLE TEST (id integer, name text)")
<pysqlite2.dbapi2.Cursor object at 0x00CDC1A0>
>>> cur.execute("INSERT INTO TEST VALUES (?, ?)", (1, "wow"))
<pysqlite2.dbapi2.Cursor object at 0x00CDC1A0>
>>> cur.execute("select * from TEST")
<pysqlite2.dbapi2.Cursor object at 0x00CDC1A0>
>>> cur.next()
(1, u'wow')
>>>

Martin

Adriano Monteiro wrote:
> Hi,
>
> It doesn't seen to work with me (or I cannot see the error at my code... :-/)
>
>>>> import sqlite
>>>> c = sqlite.connect("/tmp/t")
>>>> cur = c.cursor()
>>>> cur.execute("CREATE TABLE TEST (id integer, name text)")
>>>> cur.execute("INSERT INTO TEST VALUES (?, ?)", (1, "wow"))
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/site-packages/sqlite/main.py", line 255, in execute
>    self.rs = self.con.db.execute(SQL % parms)
> TypeError: not all arguments converted during string formatting
>
> What am I doing wrong??

Reply via email to