user3346746
user3346746

Reputation: 327

SQLite database is locked

How do I sort this one out?

code:

c.execute("INSERT INTO INPUT33 (NAME) VALUES (?);", (name3,))      
c.execute("select MAX(rowid) from [input33];")
conn.commit()      
for rowid in cursor:break         
for elem in rowid:
    m = elem    
    print(m)
    c.execute("select MAX(rowid) from [input];")                    
    for rowid in c:break
    for elem in rowid:                            
    m = elem   
    c.execute("DELETE FROM input WHERE rowid = ?", (m,))
    conn.commit()

After running this, i get this:

sqlite3.OperationalError: database is locked

Upvotes: 3

Views: 1075

Answers (1)

Prashant Shilimkar
Prashant Shilimkar

Reputation: 8830

Taken from Python Docs

When a database is accessed by multiple connections, and one of the processes modifies the database, the SQLite database is locked until that transaction is committed. The timeout parameter specifies how long the connection should wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds).

Upvotes: 2

Related Questions