Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3.OperationalError: database is locked

Tags:

python

sqlite

I'm trying to insert all values of a list to my sqlite3 database. When I simulate this query by using the python interactive interpreter, I am able to insert the single value to DB properly. But my code fails while using an iteration:

...
connection=lite.connect(db_name)
cursor=connection.cursor()
for name in match:
         cursor.execute("""INSERT INTO video_dizi(name) VALUES (?)""",(name,))
connection.commit()
...

error:cursor.execute("""INSERT INTO video_dizi(name) VALUES (?)""",(name,))
sqlite3.OperationalError: database is locked

Any way to overcome this problem?

like image 651
Fish Avatar asked Apr 03 '11 13:04

Fish


Video Answer


1 Answers

Do you have another connection elsewhere in your code that you use to begin a transaction that is still active (not committed) when you try to commit the operation that fails?

like image 100
hasseg Avatar answered Oct 20 '22 04:10

hasseg