c# - 不能使用 SQLite WAL 模式

标签 c# sqlite

我在 SQLite 上使用带有 NHibernate 的 C#。 System.Data.SQLite 版本 1.0.88 SQLite 版本 3.7.17

我最近发现了 SQLite WAL mode它看起来正是我需要的。 问题是我似乎无法让它工作。

文档简单地说明:

To convert to WAL mode, use the following pragma:

PRAGMA journal_mode=WAL;

The journal_mode pragma returns a string which is the new journal mode. On success, the pragma will return the string "wal". If the conversion to WAL could not be completed (for example, if the VFS does not support the necessary shared-memory primitives) then the journaling mode will be unchanged and the string returned from the primitive will be the prior journaling mode (for example "delete").

我已经在代码中尝试了这两个:

ISQLQuery query = session.CreateSQLQuery("PRAGMA journal_mode=WAL;");
object result = query.UniqueResult();

并在SQLiteman内管理应用。

在每种情况下,我都会得到“删除”的返回值。即数据库未能进入 WAL 模式。 问题是,我不知道为什么。我在文档中看到的唯一可能是您的文件系统不支持共享内存原语,但我使用的是 Win 7,所以这不是问题。

关于如何启用 WAL 模式或弄清楚它为何不起作用的任何想法?

最佳答案

尝试在连接构建器上设置编译指示。

SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder();
connBuilder.JournalMode = SQLiteJournalModeEnum.Wal;

看看这个: System.data.sqlite - Activating WAL Journal Mode

关于c# - 不能使用 SQLite WAL 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19111064/

相关文章:

sql - 如何选择集合中最后一个非 NULL 列

sql - SELECT 获取数据还是将其存储在字段中?

ios - 将 NSMutableDictionary 插入 SQLite 数据库的 1 个单元格

c# - 使用 C# 缩小 Jpeg 图像的效果不佳

c# - 过滤用户输入的实践

c# - 用于在 C# 中存储关键字和同义词的数据结构?

c# - C#中如何调用基于XML-RPC规范的API?

android - 回收站 View 未正确更新

iphone - 无法在 ios 上打开 sqlite 数据库