使用SQLite數據庫時注意多進程並發的錯誤處理


sqlite3.OperationalError

sqlite3. connect ( database [, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements ] )

Opens a connection to the SQLite database file database. You can use ":memory:" to open a database connection to a database that resides in RAM instead of on disk.

When a database is accessed by multiple connections, and one of the processes modifies the database, the SQLite database is locked until that transaction is committed. The timeout parameter specifies how long the connection should wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds).

貌似多線程情況下,可以設置

check_same_thread 並設置串行模式,解決並發的問題  但自己沒測過,只是參考別人的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM