try:
conn=self.connect()
curs = conn.cursor()
curs.execute(_sql)
rows = curs.fetchall()
# for record in rows:
# self.hostList.append(record[1])
conn.close()
return rows
except Exception,e:
self.log.log(str(e))
exit(0)
这样的写法就有点类似于PHP中的
fetchall()会返回 ((2L, 'ba'), (3L, 'bca'))
遍历这个结果集的方法:
for ele in rows:
print ele[1]
元组中套元组!
阅读(956) | 评论(0) | 转发(0) |