ยปCore Development>Code coverage>Doc/includes/sqlite3/executemany_1.py

Python code coverage for Doc/includes/sqlite3/executemany_1.py

#countcontent
1n/aimport sqlite3
2n/a
3n/aclass IterChars:
4n/a def __init__(self):
5n/a self.count = ord('a')
6n/a
7n/a def __iter__(self):
8n/a return self
9n/a
10n/a def __next__(self):
11n/a if self.count > ord('z'):
12n/a raise StopIteration
13n/a self.count += 1
14n/a return (chr(self.count - 1),) # this is a 1-tuple
15n/a
16n/acon = sqlite3.connect(":memory:")
17n/acur = con.cursor()
18n/acur.execute("create table characters(c)")
19n/a
20n/atheIter = IterChars()
21n/acur.executemany("insert into characters(c) values (?)", theIter)
22n/a
23n/acur.execute("select c from characters")
24n/aprint(cur.fetchall())