当前位置:首页 > 数据库 > SQlite

python sqlite中通过字段名获取查询结果

sqlite3 con = sqlite3.connect("mydb") con.row_factory = sqlite3.Row cur = con.cursor() cur.execute("select name_last, age from people") for row in cur: assert row[0] == row["name_last"] assert row["name_last"] == row["nAmE_lAsT"] assert row[1] == row["age"] assert row[1] == row["AgE"] #何问起 hovertree.com

 

MySQLdb的实现方法是: 
conn=MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) 
或者用MySQLdb.cursors.SSDictCursor。前者数据存储在客户端,后者数据存储在服务器。

推荐:http://www.cnblogs.com/roucheng/p/pythonstring.html

python sqlite中通过字段名获取查询结果

标签:

本文系统来源:http://www.cnblogs.com/roucheng/p/pythonziduan.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!