我想在我的數(shù)據(jù)庫中增加一列,我該怎么做?if result[0] is True and result[1] != "": # a win your_details["score"] = your_details["score"] + 1 lbl_status["text"] = "Game over, You won! You(" + str(your_details["score"]) + ") - " \ "" + opponent_details[ "name"] + "(" + str(opponent_details["score"]) + ")" req = 'UPDATE INTO users("nb_win") VALUES("nb_win + 1")' infos = your_details["score"] print(infos) try: cursor.execute(req, infos) db_connection.commit() except mysql.Error as err: print(err)def connect(): global your_details if len(ent_name.get()) < 1: tk.messagebox.showerror(title="ERROR!!!", message="You MUST enter your first name <e.g. John>") else: your_details["name"] = ent_name.get() print(ent_name.get()) connect_to_server(ent_name.get()) req = 'INSERT INTO users(user_name) VALUES("'+ ent_name.get()+'")' infos = ent_name 如果有人可以幫助我,謝謝你的幫助!
1 回答

白衣非少年
TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊
你想要一個(gè)update
聲明。假設(shè)您的表的主鍵是id
,那將是:
UPDATE users SET nb_win = nb_win + 1 WHERE user_name = ?
查詢中的?
應(yīng)替換為您要遞增id
的行的。nb_win
添加回答
舉報(bào)
0/150
提交
取消