gpt4 book ai didi

multithreading - Peewee Sqlite 在内存数据库中的共享

转载 作者:行者123 更新时间:2023-12-03 13:16:55 25 4
gpt4 key购买 nike

阅读这篇文章,我了解到可以跨线程共享内存数据库:

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')

关于multithreading - Peewee Sqlite 在内存数据库中的共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53146828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com