|
连接了数据库,取数。但是用fetchall,取出来的数包含的字段名
[ {'story': 34289, 'estimate': 0.0}, {'story': 26791, 'estimate': 0.0}, {'story': 26791, 'estimate': 8.0}]
取出的是类似于以上的dictionary的一个list
我想把story一样的项目做一个分类汇总.
就是类似得到:
story estimate
34289 0
26791 8
请问该如何操作?先谢过了。
目前的代码是:
try:
with connection.cursor() as cursor:
sql = "select story, estimate FROM zt_task"
cursor.execute(sql)
result = cursor.fetchall()
for row in result:
print(result) |
|