This topic created in 3609 days ago, the information mentioned may be changed or developed.
dbstr = "select * from list"
db.execute(dbstr)
rows = db.fetchall()
for row in rows:
print(row.id)
用 pypyodbc 连接 Access 数据库,我想取出 list 表中的每条记录的 id ,但是
运行时报错: AttributeError: 'Row' object has no attribute 'id'
把 print(row.id)改成 print(row[0])时通过。
这样其实也能用,但是通用性就差了好多,如果我在 id 字段的前边插入一个新字段,那么相应的程序代码也得从 0 改成 1 ,有什么办法能用 row.id 表示吗?
1 replies • 2016-06-20 21:13:39 +08:00
 |
|
1
Kilerd Jun 20, 2016
你需要一个 ORM
|