在azure上部署Django webapp时出现“数据库已锁定”错误

2024-09-30 01:32:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在azure上部署django webapp。它出现在web上完全是功能性的,除了一件事,它不允许我在WebSH上创建超级用户。每次我尝试运行python manage.py createsuperuser并且在给出所有凭据之后,它都会抛出一个错误

django.db.utils.OperationalError: database is locked

我使用的是django的默认数据库。这可能是什么原因


Tags: django用户pywebdbmanage部署错误
1条回答
网友
1楼 · 发布于 2024-09-30 01:32:27
SQLite is meant to be a lightweight database, and thus can't support a high level of concurrency. OperationalError: database is locked errors indicate that your application is experiencing more concurrency than sqlite can handle in default configuration. This error means that one thread or process has an exclusive lock on the database connection and another thread timed out waiting for the lock the be released.

Python's SQLite wrapper has a default timeout value that determines how long the second thread is allowed to wait on the lock before it times out and raises the OperationalError: database is locked error.

If you're getting this error, you can solve it by:

    Switching to another database backend. At a certain point SQLite becomes too "lite" for real-world applications, and these sorts of concurrency errors indicate you've reached that point.
    Rewriting your code to reduce concurrency and ensure that database transactions are short-lived.
    Increase the default timeout value by setting the timeout database option

相关问题 更多 >

    热门问题