I\'m not sure what to call this besides an \"accumulated\" column.
I have a MySQL table with a column that looks like
+---+
|val|
+---+
| 1 |
| 4 |
|
I would use a cursor:
>>> import MySQLdb
>>> db = MySQLdb.connect("localhost","username","password","test")
>>> cur = db.cursor()
>>> cur.execute("select myval from mytable")
>>> rs = cur.fetchall()
>>> accumulator = 0
>>> for r, in rs:
... accumulator += r
... print r, accumulator
...
1 1
4 5
6 11
3 14
2 16
5 21