gpt4 book ai didi

database - 使用 Haskell 的 HDBC,我可以跨多个线程使用单个 SQLite 连接吗?

转载 作者:太空狗 更新时间:2023-10-30 01:57:48 28 4
gpt4 key购买 nike

如果我想跨多个线程使用 Haskell 的 HDBC 从 SQLite 数据库查询(读取),我可以使用单个连接,还是每个线程都应该有自己的连接?谢谢。

最佳答案

我搜索了 hdbc-sqlite 代码并找到了这个 comment :

Logic for handling counts of changes: look at the total changes before and after the query. If they differ, then look at the local changes. (The local change counter appears to not be updated unless really running a query that makes a change, according to the docs.)

This is OK thread-wise because SQLite doesn't support using a given dbh in more than one thread anyway.

官方 Sqlite 文档有一整页关于这个 topic

FAQ说:

(5) Can multiple applications or multiple instances of the same application access a single database file at the same time?

Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at any moment in time, however.

此信息将排除您的两种方法。或许你可以为此编写一些测试来证明这些信息是错误的。

关于database - 使用 Haskell 的 HDBC,我可以跨多个线程使用单个 SQLite 连接吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16886718/

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