2
我有一個Kivy代碼,其中輸出爲:檢索的MySQL與Kivy
我想更換Box No.
與從MySQL返回的字符串
到目前爲止,我已經嘗試實現MySQL到python腳本:
class RemoveScreen(MyLayout):
def __init__(self,**kwargs):
db = MySQLdb.connect("localhost", "root", "[PASSWORD]", "tcs_microrage_crm")
cursor=db.cursor()
self.var = StringVar()
self.label1 = Label(self, text=0, textvariable=self.var)
myvar=str(self.var)
#http://stackoverflow.com/questions/775296/python-mysql-parameterized-queries
cursor.execute("SELECT part_name FROM stock_lists WHERE part_number = %s", (myvar))
self.myvar=StringVar()
self.myvar.set(cursor.fetchone())
self.label2 = Label(self, text=0, textvariable=myvar)
但是這並沒有奏效。
問:如何執行MySQL查詢並打印kv文件中的單個字符串。