多线程SQLite中 [英] Multithreading in Sqlite

查看:473
本文介绍了多线程SQLite中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用System.data.sqlite用于连接到SQLite数据库,按照该 sqlite的文件,用户可以使用 SQLITE_OPEN_NOMUTEX 标志作为连接字符串的一部分支持多线程。但我找不到它接受标志在连接字符串中的任意键。难道是默认启用?如果不是我怎么能这样做呢?

I am using System.data.sqlite for connecting to Sqlite Database, as per the Sqlite documentation, users can enable multithreading by using SQLITE_OPEN_NOMUTEX flag as part of connection string. But I couldn't find any key in the connection string which accepts flag. Is it enabled by default? if not how can I do this?

推荐答案

在穿线模式由编译时,启动或运行时选项决定。更多细节在这里:

The threading mode is determined by compile time, startup or runtime options. More details here:

HTTP:// WWW。 sqlite.org/threadsafe.html

连载说的文档是,这意味着你的罚款从多个线程使用默认的 - 它会守护你。如果您想了解更多的并行性,可以使用多线程模式。

The docs say serialized is the default which means you're fine to use from multiple threads - it will guard you. If you want more parallelism, you can use multi-threaded mode.

如果您在多线程模式下使用它,请确保调用一个给定的连接同步。如果你想要并行工作,使用多个连接和后卫的连接。

If you use it in multi-threaded mode, make sure that calls are synchronized for a given connection. If you want parallel work, use multiple connections and guard the connection.

API本身通过采取db对象(连接)作为参数传递给许多功能暗示了这一点,你调用顺序。例如,看一下你打电话得到一个错误以下功能:

The API itself hints at this by taking the db object (connection) as an argument to many functions that you call sequentially. For example, look at these functions that you call to get an error:

int sqlite3_errcode(sqlite3 *db); 
const char *sqlite3_errmsg(sqlite3*);

这篇关于多线程SQLite中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆