Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 402
user3346746 Avatar asked Jul 11 '26 10:07

user3346746


1 Answers

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).

like image 165
Prashant Shilimkar Avatar answered Jul 13 '26 12:07

Prashant Shilimkar