有什么好的方法处理数据库返回的查询结果fetchall?
数据库返回来的查询是元组,如何格式化处理好?特别是日期方面
放在pandas里。
http://stackoverflow.com/questions/12047193/how-to-convert-sql-query-result-to-pandas-data-structure 本帖最后由 ghostwwl 于 2016-09-02 12:59 编辑
我以前好像是这么干的
get_fields = ('id', 'name', 'title');
sql= 'select %s from aaa' % (','.join(get_fields)
结果:
r = []
for item in xxx:
result = dict(zip(get_fields), item))
r.append(result)
我这样干了,结果也是我想要的。回复 3# ghostwwl
页:
[1]