我尝试使用pymsql在服务器上运行一个简单的查询,这不应该是一个问题。我现在差点拉我的头发。我错过了什么。
import pymysql
connection = pymysql.connect(user='mak_aba', passwd='password',host='localhost',database='baba')
cursor = connection.cursor(buffered=True)
query = ("SELECT * FROM `orders`")
cursor.execute(query)
for item in cursor:
print item
答案 0 :(得分:3)
connection = pymysql.connect(host='localhost', port=3306, user='mak_aba', passwd='password', db='baba')
此处example
试试这个
import pymysql
connection = pymysql.connect(host='localhost', port=3306, user='mak_aba', passwd='password', db='baba')
cursor = connection.cursor()
query = ("SELECT * FROM `orders`")
cursor.execute(query)
for item in cursor:
print(item)