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 | |
---|
1 | import sqlite3
|
---|
2 |
|
---|
3 | class 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 |
|
---|
13 | con = sqlite3.connect(":memory:")
|
---|
14 | con.create_aggregate("mysum", 1, MySum)
|
---|
15 | cur = con.cursor()
|
---|
16 | cur.execute("create table test(i)")
|
---|
17 | cur.execute("insert into test(i) values (1)")
|
---|
18 | cur.execute("insert into test(i) values (2)")
|
---|
19 | cur.execute("select mysum(i) from test")
|
---|
20 | print cur.fetchone()[0]
|
---|
Note:
See
TracBrowser
for help on using the repository browser.