mardi 22 mars 2016

Database lock SQlite when going through python for loop

I have a weird issue with my database getting locked on running the following for loop. If I take the 4 function calls out of the loop it and run it they do not lock my database.... I have triple checked to make sure I close the database at the end of each function call so I am wondering if the for loop is not waiting for the functions to be done before the next iteration... If that is what is going on how do I make it wait?

Thanks for all your help guys!

        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)

Full Error:

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

Aucun commentaire:

Enregistrer un commentaire