数据库锁定SQlite在进行python for循环时

时间:2016-03-22 23:19:52

标签: python sqlite

我有一个奇怪的问题,我的数据库被锁定运行以下for循环。如果我从循环中取出4个函数调用它并运行它们就不会锁定我的数据库....我已经检查了三次以确保在每个函数调用结束时关闭数据库所以我想知道是否为循环不等待在下一次迭代之前完成的函数......如果是这样的话我该如何让它等待?

感谢你们的帮助!

        c.execute("SELECT playerName FROM player")
        for row in c:
            for username in row:
                PaytheBets.PaytheHops(die1, die2, username)
                PaytheBets.PaytheField(theroll, username)
                PaytheHouse.RemoveThePass(username)
                PaytheHouse.RemoveHops(username)

完全错误:

What is Die1?
1
What is Die2
2
0
3
Traceback (most recent call last):
  File "C:/Users/Ray/Desktop/TwitchBot/plugins/CRAPS/twitchBot.py", line 163, in <module>
    parse_message(message)
  File "C:/Users/Ray/Desktop/TwitchBot/plugins/CRAPS/twitchBot.py", line 100, in parse_message
    whats_the_roll()
  File "C:/Users/Ray/Desktop/TwitchBot/plugins/CRAPS/twitchBot.py", line 119, in whats_the_roll
    temppoint = runthegame(die1, die2, thepoint)
  File "C:\Users\Ray\Desktop\TwitchBot\plugins\CRAPS\CrapsUpdated.py", line 32, in runthegame
    PaytheHouse.RemoveThePass(username)
  File "C:\Users\Ray\Desktop\TwitchBot\plugins\CRAPS\RemoveBets.py", line 77, in RemoveThePass
    conn.commit() #confirms changes to the databae
sqlite3.OperationalError: database is locked

0 个答案:

没有答案