c# - 如何以WAL方式打开SQLite连接

标签 c# sqlite wal

在 C# 中,如何打开 SQLite 连接 in WAL mode

以下是我在正常模式下的打开方式:

SQLiteConnection connection = new SQLiteConnection("Data Source=" + file);
connection.Open();
// (Perform my query)

最佳答案

如何在 SQLiteConnection 连接字符串中指定工厂方法?

例如

public static class Connection
{
    public abstract SQLiteConnection NewConnection(String file);
}

public class NormalConnection : Connection 
{
  public override SQLiteConnection NewConnection(String file)
  {
     return new SQLiteConnection("Data Source=" + file);
  }
}

public class WALConnection : Connection 
{
  public override SQLiteConnection NewConnection(String file)
  {
    return new SQLiteConnection("Data Source=" + file + ";PRAGMA journal_mode=WAL;"
  }
}

代码没有经过测试,希望大家能看懂,使用的时候就可以了。

   SQLiteConnection conWal = new WALConnection(file);
    conWAL.Open();

    SQLiteConnection conNormal = new NormalConnection(file);
    conNormal.Open();

关于c# - 如何以WAL方式打开SQLite连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15870104/

相关文章:

c# - 使用 EntityFramework 的模式?

c# - 在 EF Core 中进行 SQL 跟踪期间丢失参数值

c# - SQLite 错误 14 : 'unable to open database file' if in root folder

sql - PostgreSQL 13 - WAL - 最后文件更新日期不变

c++ - 如果我为多个编写器使用额外的互斥锁,我可以在 SQLite3 中使用 WAL 模式吗?

c# - 难道我们不应该将 using block 与 Unity3D 的 WWW 类一起使用(实现 IDisposable)吗?

c# - 如何读取 Excel 文件?

python + sqlite3 : using IS NOT in a join query

python - 如何将 Beautiful Soup 输出保存到我​​的 SQLite 数据库中?

SQLite:有没有什么方法可以在没有 mmap() 函数的情况下使用 WAL?