symbian-qemu-0.9.1-12/python-2.6.1/Doc/includes/sqlite3/executemany_1.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 import sqlite3
       
     2 
       
     3 class IterChars:
       
     4     def __init__(self):
       
     5         self.count = ord('a')
       
     6 
       
     7     def __iter__(self):
       
     8         return self
       
     9 
       
    10     def next(self):
       
    11         if self.count > ord('z'):
       
    12             raise StopIteration
       
    13         self.count += 1
       
    14         return (chr(self.count - 1),) # this is a 1-tuple
       
    15 
       
    16 con = sqlite3.connect(":memory:")
       
    17 cur = con.cursor()
       
    18 cur.execute("create table characters(c)")
       
    19 
       
    20 theIter = IterChars()
       
    21 cur.executemany("insert into characters(c) values (?)", theIter)
       
    22 
       
    23 cur.execute("select c from characters")
       
    24 print cur.fetchall()