編輯:經過一些測試後,我發現它不是失敗的加點方法。Sqlite更新不工作正確 - python
我正在爲一個irc bot做一個小遊戲。這種方法會更新數據庫中的分數'分數',只有兩名玩家。這是一個sqlite數據庫。這主要是更新SQL不正確。
感謝
def addpointo(phenny, id, msg, dude):
try:
for row in c.execute("select score from score where id = '0'"):
for bow in c.execute("select score from score where id = '1'"):
if int(row[0]) == 3:
phenny.say("Winner is " + dude)
clear("score") # clear db
clear("sap") # clear db
elif int(bow[0]) == 3:
phenny.say("Winner is " + dude)
clear("score") # clear db
clear("sap") # clear db
else:
phenny.say(msg)
s = c.execute("select score from score where id=?", id)
a = int(s.fetchone()[0]) + 1
print a
c.execute("update score SET score =? where id =?", (a, id)) #here i got some prolem
conn.commit()
except Exception:
phenny.say("Error in score. Try to run '.sap clear-score' and/or '.sap clear-sap'")
pass
,這是我創造的得分分貝
def createscore():
if not (checkdb("score") is True):
c.execute('''create table score (id int, score int)''')
c.execute('insert into score values (0, 0)')
conn.commit()
c.execute('insert into score values (1, 0)')
conn.commit()
錯誤信息的方式:參數是不支持的類型
你是什麼意思是「不工作的權利」嗎?你遇到了什麼錯誤? – CanSpice 2011-01-19 21:58:31
你有沒有看過sqlite模塊?另外,你應該閱讀使用SQL。你的設計很明顯缺乏對使用數據庫的理解。 – Falmarri 2011-01-19 22:00:10
我只得到這個錯誤:參數是不受支持的類型 – Enumto 2011-01-19 22:06:11