Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我从 presto 命令得到这样的结果:
a| b| c --+--+------ 1 | 3| 6 2 | 4| 5
我知道cursor.fetchall()所有数据和cursor.fetchone()单行。
cursor.fetchall()
cursor.fetchone()
现在,我想从特定列中获取所有数据,例如[1, 2]
[1, 2]
有没有办法解决这个问题?
看到一些东西并修改它以解决问题
class reg(object): def __init__(self, cursor, row): for (attr, val) in zip((d[0] for d in cursor.description), row) : setattr(self, attr, val)
并有一个循环来获取列
for row in cursor.fetchall(): r = reg(cursor, row) print r.a