The error "database is locked" in SQLite"

Source: Internet
Author: User

Principle: The file database SQLite allows multiple processes/threads to read at the same time, but only one thread to write at the same time. During write operations, the database file is deprecated. In this case, any other read/write operations are blocked. If the blocking duration exceeds 5 seconds (the default value is 5 seconds, if you can recompile SQLite to modify the timeout value, the system reports the "database is locked" error.

Therefore, when operating SQLite, you should immediately close the connection; after opening the connection, try to reduce the time-consuming operations as much as possible.

Knowing the principles and precautions does not mean you will not make mistakes. If the following section uses sqlalchemy to operate SQLiteCode:

 

I believe you will see the problem with this code and understand how to modify it. But I did not make this mistake once, and before I made the same mistake many times, I knew the principle long ago, but still made a mistake. I think it's too rash and casual.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.