sql = select id,name from table
res = session.execute(sql)
for row in res:
print row
此代码将执行sql(无名称)的结果打印为数组。如何打印结果作为哈希? (带身份证,姓名)
答案 0 :(得分:0)
试试这个:
columns = ('id', 'name')
sql = 'select %s from table' % ','.join(columns)
res = session.execute(sql)
for row in res:
rowDict = dict(zip(columns, row))