# coding:utf-8 import MySQLdb import sys conn = MySQLdb.connect('localhost', 'root', '', 'test') cur = conn.cursor() with conn: cur.execute("select * from yhxtest") # 输出结果每条记录为一个元组 # rows=cur.fetchall() # for row in rows: # print row # 输出结果为一个元组 numrows =int(cur.rowcount) for i in range(numrows): row = cur.fetchone() print row[0],row[1]
python:mysql查询
最新推荐文章于 2024-04-03 16:53:37 发布