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

标签 database sqlite haskell concurrency hdbc

如果我想跨多个线程使用 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/

相关文章:

mysql - #1932 引擎中不存在表 'tablename'

sqlite - macports apache2安装缺少的pdo驱动程序

haskell - 我的二叉搜索树成员资格功能测试有什么问题?

php - 按时区从sql表中排序和选择

mysql - 将 MySQL 数据库表导出到多个文件并在 MySQL 数据库中导入巨大的数据集

php - 如何从 MYSQL 数据库中检索特定 ID 的详细信息

python - 使用 Tkinter 在 SQLite3 表中插入变量时出现 NameError 和 AttributeError?

java - 如何使用自定义列表适配器检查 ListView 是否为空

haskell - GHC 中函数参数的内联

haskell - 如何使用 "Of"镜头? ( haskell )