我在python2.5中使用sqlite3.我已经创建了一个如下所示的表:
create table votes (
bill text,
senator_id text,
vote text)
我用这样的方式访问它:
v_cur.execute("select * from votes")
row = v_cur.fetchone()
bill = row[0]
senator_id = row[1]
vote = row[2]
我希望能够做的是让fetchone(或其他方法)返回一个字典,而不是一个列表,这样我就可以通过名称而不是位置来引用该字段.例如:
bill = row['bill']
senator_id = row['senator_id']
vote = row['vote']
我知道你可以用MySQL做到这一点,但有人知道如何用SQLite做到这一点吗?
谢谢