Re: trying usage-guide tutorial code
giuseppe massimo bertani <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Alle 09:00, mercoledì 30 maggio 2007, hai scritto: > installed pysqlite 2.3.3 and changed the import line as in the tutorial: > > from pysqlite2 import dbapi2 as sqlite > > now it works. Спасибо большой Сергей! > > > Alle 18:45, martedì 29 maggio 2007, Sergey Chernov ha scritto: > > Try newer version of pysqlite; I've changed your import to > > > > import sqlite3 as sqlite > > > > and it works just fine. > > > > -----Original Message----- > > From: [email protected] > > [mailto:[email protected]] On Behalf Of giuseppe massimo > > bertani > > Sent: Tuesday, May 29, 2007 5:11 PM > > To: [email protected] > > Subject: [pysqlite] trying usage-guide tutorial code > > > > Hello all, > > > > I've just started to experiment sqlite through python 2.4.2 on a Suse10.1 > > box. The pysqlite documentation was not present with > > the packet, so I had to download it from http://initd.org/tracker/pysqlite. > > > > After a look at the tutorial in the user guide, I arranged the examples > > showed in a test.py file > > and executed it in order to produce the same printouts > > described in the tutorial. > > > > Sadly, the example 4 fails in this way: > > --------------------------------- > > #Example 4 > > #Let's insert more people into the people table: > > > > newPeople = (('Lebed', 53), ('Zhirinovsky' , 57)) > > > > #for person in newPeople: > > # cur.execute("insert into people (name_last, age) values (?,?)", person) > > > > cur.executemany("insert into people (name_last, age) values (?, ?)", > > newPeople) > > > > # The changes will not be saved unless the transaction is committed > > explicitly: > > con.commit() > > ----------------------------------- > > gbertani@gbertani:sqlite>python test.py > > [('Putin', 51), ('Yeltsin', 72)] > > Putin is 51 years old. > > Yeltsin is 72 years old. > > Putin is 51 years old. > > Yeltsin is 72 years old. > > Traceback (most recent call last): > > File "test.py", line 63, in ? > > cur.executemany("insert into people (name_last, age) values (?, ?)", > > newPeople) > > File "/usr/lib/python2.4/site-packages/sqlite/main.py", line 276, in > > executemany > > self.execute(query, _i) > > 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 > > gbertani@gbertani:sqlite> > > > > ----------------------------------- > > > > Above is showed the version using executemany(), but the for loop with > > execute() fails in the same way. The unique way > > I found to add rows in the table is to use an unique string argument to > > execute(), that means embed the argument in the sql string. > > Each time I try to use the second argument of execute() or executemany() I > > got the error. > > > > In attachment, you can find my test.py. > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ pysqlite mailing list [email protected] http://lists.initd.org/mailman/listinfo/pysqlite