Re: trying usage-guide tutorial code
"Sergey Chernov" <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Organization | Tancher |
| Message-ID | <012a01c7a210$c4153890$0202fea9@SergeyhCelsius> |
Try newer version of pysqlite; I've changed your import to import sqlite3 as sqlite and it works just fine. -----Original Message----- From: pysqlite-bounces-IAPFreCvJWPBWskQ1e/[email protected] [mailto:pysqlite-bounces-IAPFreCvJWPBWskQ1e/[email protected]] On Behalf Of giuseppe massimo bertani Sent: Tuesday, May 29, 2007 5:11 PM To: pysqlite-IAPFreCvJWPBWskQ1e/[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 pysqlite-IAPFreCvJWPBWskQ1e/[email protected] http://lists.initd.org/mailman/listinfo/pysqlite
smime.p7s
(application/x-pkcs7-signature, 3 KB) - not displayed