我試圖用python GUI連接MySQL數據庫。但是這部分代碼返回一個空集。我不確定我的代碼有什麼問題,因爲沒有錯誤代碼...請幫助!將MySQL與Python連接(GUI)
def ButtonPressed (self):
print("Finding Parts!")
self.ProdNum = self.aVar.get()
print("Entry text was:", self.ProdNum)
self.db = mysql.connector.connect (user='ezhu', password='<password>', host='127.0.0.1', database='centricsit_prices')
self.query = ("SELECT sd, sy, price FROM css_hp WHERE prod_num = '%s'")
self.cursor = self.db.cursor()
self.cursor.execute (self.query, (self.ProdNum))
self.results = self.cursor.fetchall()
print (self.results)
self.cursor.close()
@alecxe:好的,不像127.0.0.1可以用來獲取OP的數據庫...... –