这是我的剧本。
import _mysql
db=_mysql.connect("localhost","01","","z")
db.query("select id from a limit 2")
result = db.store_result()
while True:
record = result.fetch_row()
if not record: break
print record
(执行和结果)是:
[root@ooo ~]# python a.py
(('1',),)
(('2',),)
[root@ooo ~]#
结果是正确的但我希望它附加所有结果并简单地打印(基于上面的输出)
12
答案 0 :(得分:0)
import _mysql
db=_mysql.connect("localhost","sundar","","test")
db.query("select username from auth_user")
result = db.store_result()
r=""
while True:
record = result.fetch_row()
if not record: break
elif record is None:break
else:r+= record[0][0]
print r