编辑:经过一些测试,我发现添加分数的方法并没有出错。
我正在为一个IRC机器人开发一个小游戏。这个方法将会在名为“score”的数据库中更新得分,只有两个玩家参与。这是一个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()
错误信息:参数类型不受支持。