當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python sqlite3.threadsafety用法及代碼示例

用法:

sqlite3.threadsafety

DB-API 所需的整數常量,說明sqlite3 模塊支持的線程安全級別。當前 hard-coded 到 1 ,意思是 “Threads may share the module, but not connections.” 但是,這可能並不總是正確的。您可以使用以下查詢檢查底層 SQLite 庫的編譯時線程模式:

import sqlite3
con = sqlite3.connect(":memory:")
con.execute("""
    select * from pragma_compile_options
    where compile_options like 'THREADSAFE=%'
""").fetchall()

請注意,SQLITE_THREADSAFE levels 與 DB-API 2.0 threadsafety 級別不匹配。

相關用法


注:本文由純淨天空篩選整理自python.org大神的英文原創作品 sqlite3.threadsafety。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。