1

I cannot execute UPDATE statements in my Flask App deployed to Azure App Service (Linux). It says:

Database is Locked.

SELECT statements are executed as expected. On the local machine work UPDATE statements as expected.

I have tried to change the isolation_level (DEFERRED, EXCLUSIVE, IMMEDIATE). I have also tried to CHMOD on the data folder but that looks right.

with sql.connect(connstring) as con:
cur = con.cursor()
cur.execute("Update INNOVATIONPOWER_MESSAGES SET innovative = 0 WHERE id = 21187")
con.commit()
Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63

1 Answers1

0

Checking other similar questions (OperationalError: database is locked), it seems like the general response from users is that they had bad code that wasn't closing the sessions properly. High volume applications, will eventually outgrow SQLite's concurrency capabilities, but if you suspect that's not the case for your application, try double checking your code in case it isn't handling (closing) sessions properly.

Rewriting your code to reduce concurrency and ensure that database transactions are short-lived.

Sergio Pulgarin
  • 869
  • 8
  • 20
  • I have restarted the app services and ensured that this is the first SQL statement to the database. Event the results is "Database is Locked". – Erwin Koens Sep 06 '19 at 16:04