【发布时间】:2012-07-17 23:59:25
【问题描述】:
编辑:经过一些测试,我发现它不是失败的 addpoint 方法。
我正在为一个 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()
错误信息:参数的类型不受支持
【问题讨论】:
-
“工作不正常”是什么意思?你遇到了什么错误?
-
你看过 sqlite 模块吗?此外,您应该阅读使用 sql。您的设计明显缺乏对使用数据库的意义的理解。
-
我只得到这个错误:参数的类型不受支持
-
@Falmarri 是的,我以前使用过 sql,但从未使用过 python,但有时必须是第一次