multithreading - Peewee Sqlite 在内存数据库中的共享
问题描述
阅读这篇文章,我了解到可以跨线程共享内存数据库:
https://stackoverflow.com/a/24708173/7754093
使用 sqlite python 包我可以做到这一点:
sqlite3.connect('file:foobar_database?mode=memory&cache=shared', uri=True)
如何在 Peewee 中做到这一点?我找不到任何描述它的文档。
解决方案
如果您的sqlite3
模块可以成功连接到共享内存数据库,则以下操作将起作用:
from peewee import *
sqlite_db = SqliteDatabase('file:foobar_database?mode=memory&cache=shared')
推荐阅读
- ansible - Ansible 工作站配置 - 图标文件的校验和错误
- asn.1 - ASN.1 中隐式和显式标签的编码
- r - 将列格式化为 r 中的时间
- mysql - 有什么更好的方法来查找表 Y 中与表 X 的 PK 相关的所有 id 是否都存在于 mysql 的表 Z 中?
- sql - SQL 从一个表更新到另一个 ID 匹配的表
- python - pygame.sprite.groupcollide() 尝试在 pygame 中实现碰撞时不起作用
- c++ - 为什么我的重载函数调用不明确?
- twilio - Whatsapp - 客户解决方案查询
- javascript - 避免浏览器弹出
- rxjs - 什么是 rxjs 等价于 Array.some()?