如何解析sqlite3锁(sqlite_busy,sqlite_misuse) [英] How can i resolve sqlite3 locks (sqlite_busy,sqlite_misuse)
问题描述
大家好。我想与您分享我的问题,如下所示。我有两个独立的程序都在linux系统中运行。一个程序是在sqlite3数据库中的表(我们称之为表A)中编写(INSERT),而另一个程序读取该表。我曾经遇到过一些锁定的场合。
我的代码示例是
Hi to all. I would like to share with you my problem which is the following. I have two separate programs both operate in a linux system. One program is to write(INSERT) in a table (let's call it table A) in the sqlite3 database while the other program reads this table. I had occasions where there where some locks.
A sample of my code is
sqlite3_open(DB,&db);
if(rc!=SQLITE_OK){
memset(tempBuf, 0, sizeof tempBuf);
sprintf(tempBuf,"insert recordd in DB-1 Id: %ld Error: %s",rc,sqlite3_errmsg(db));
Log(tempBuf);
sqlite3_close(db);
return -1;
}
rc=sqlite3_prepare_v2(db,sql,-1,&res,NULL);
if(rc==SQLITE_OK){
sqlite3_bind_text(.....);
}
int step=sqlite3_step(res);
if(step!=SQLITE_DONE){
memset(tempBuf, 0, sizeof tempBuf);
sprintf(tempBuf,"set record into the DB Id: %ld Error: %s",step,sqlite3_errmsg(db));
Log(tempBuf);
}
sqlite3_finalize(res);
sqlite3_close(db);
你能来吗请帮我解决这个问题?
我尝试过的事情:
为了避免这个问题,我创建了表A的副本(让我们称之为表B),我决定让一个程序写入表A,另一个程序读取表A并写入表B.之后我有一些其他程序正在使用表B,他们插入一些数据。在这个修改之后我仍然有一些SQLITE_BUSY和SQLITE_MISUSE错误。
Can you please help me overcome this problem?
What I have tried:
To avoid this problem i created a replica of the table A (lets call it table B) and i decided to have one program to write to the table A and the other program to read table A and to write in table B. After this i have some other procedures that are using table B and they insert some data to them. After this modification i still have some SQLITE_BUSY and SQLITE_MISUSE errors.
推荐答案
SQLite从来就不是客户端/服务器或多用户 - 你真的会更好用MySQL或其他数据库引擎
我已经看过(很久以前)SQLite变成了一个多用户数据库,但是,这涉及到将一个包装器放在上面它的api,并使用tcp / ip发送命令和接收数据/结果 - 它的大量工作
SQLite was never meant to be client/server or multi-user - you really would be better off using MySQL or another database engine
I have seen (a very long time ago) SQLite turned into a multi-user database, but, this involved putting a wrapper on top of its api, and using tcp/ip to send commands and receive data/results - its a lot of work
这篇关于如何解析sqlite3锁(sqlite_busy,sqlite_misuse)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!