source: python/trunk/Doc/includes/sqlite3/mysumaggr.py

Last change on this file was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 470 bytes
Line 
1import sqlite3
2
3class MySum:
4 def __init__(self):
5 self.count = 0
6
7 def step(self, value):
8 self.count += value
9
10 def finalize(self):
11 return self.count
12
13con = sqlite3.connect(":memory:")
14con.create_aggregate("mysum", 1, MySum)
15cur = con.cursor()
16cur.execute("create table test(i)")
17cur.execute("insert into test(i) values (1)")
18cur.execute("insert into test(i) values (2)")
19cur.execute("select mysum(i) from test")
20print cur.fetchone()[0]
Note: See TracBrowser for help on using the repository browser.