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