import _mysql as mysql
db=mysql.connect('localhost','username','password','database')
db.query("""select * from news""")
result = db.store_result()
print result.num_rows()#two records
#how to loop? without cursor
print result.fetch_row()
问问题
5034 次
3 回答
6
您不应该导入_mysql
. 以下划线开头的符号仅供私人使用。导入MySQLdb
并阅读PEP 249以供使用。
于 2010-09-03T06:58:06.943 回答
0
我不确定你打算如何使用循环,但你可以这样做:
while x < result.num_rows():
#do something for each row
X += 1
于 2010-09-03T07:07:01.657 回答