sqlite3多线程操作问题

在项目中使用sqlite3,有时会报database is locked

两种方式

1、多线程读,多线程写,只使用共同一个数据库连接,即使用同一个SQLiteHelper连接,调用sqlite3_busy_timeout

2、多线程读,单线程写,每个线程使用各自独立的数据库连接,但是需要开启wal模式,以开启数据库连接池

开启wal通过如下语句

sql 复制代码
pragma synchronous=NORMAL;
pragma journal_mode=WAL;
pragma wal_autocheckpoint=5000;
相关推荐
神王宝宝 王者小学4 小时前
HBase: 看上去很美
大数据·数据库·hbase
io无心5 小时前
Shardingsphere5分库分表
数据库·mysql
wWYy.5 小时前
Mysql:主键索引 唯一索引 普通索引 前缀索引
数据库·mysql
宝杰X76 小时前
Android Room3 多平台数据库
android·数据库
sky_8106139 小时前
Oracle ERP 各模块业务管理功能及底层表说明
数据库·oracle
YMatrix 官方技术社区10 小时前
CittaBase vs. Neo4j :原生图性能实测与混合检索实践
数据库·功能测试·ymatrix
闲猫11 小时前
LangChain / Integrations / Integrations by component / Tool
java·数据库·langchain
xqqxqxxq12 小时前
SQL 连接查询技术笔记
数据库·笔记·sql
Databend12 小时前
从万亿级大模型到全线应用:Databend Cloud 助力头部 AI 企业构建全链路 Trace 数据管道
大数据·数据库·sql
MC皮蛋侠客12 小时前
SQLAlchemy 系列(十一):从 1.x 到 2.x——渐进迁移与数据访问层治理
数据库·python