Sqlite3.OperationalError: database is locked

I am trying to insert all list values ​​into my sqlite3 database. When I model this query using the python interactive interpreter, I can correctly insert a single value into the database. But my code does not work when using 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?

+7
python sqlite sqlite3
source share
3 answers

Do you have another connection elsewhere in your code that you use to start a transaction that is still active (not completed) when you try to perform an operation that is not running?

+10
source share

Because your database is being used by another process or connection. If you need real concurrency, use a real DBMS.

+1
source share

How this error can happen because you opened your site.db or database file in an application like DBbrowser for viewing in the interactive database interface. Just close so that everything works fine.

0
source share

All Articles