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

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

#countcontent
1n/aimport sqlite3
2n/a
3n/aclass MySum:
4n/a def __init__(self):
5n/a self.count = 0
6n/a
7n/a def step(self, value):
8n/a self.count += value
9n/a
10n/a def finalize(self):
11n/a return self.count
12n/a
13n/acon = sqlite3.connect(":memory:")
14n/acon.create_aggregate("mysum", 1, MySum)
15n/acur = con.cursor()
16n/acur.execute("create table test(i)")
17n/acur.execute("insert into test(i) values (1)")
18n/acur.execute("insert into test(i) values (2)")
19n/acur.execute("select mysum(i) from test")
20n/aprint(cur.fetchone()[0])