Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-08-2011, 08:27 AM   #1
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Rep: Reputation: 18
sqlite locking problem in C programming

I am writing a multi thread program that one thread writing to a table of database continuously and I want to read from that table by another threads during writing of the first one. but I can not it returns database lock or busy . but I heard sqlite is single write and multiple read but it does not work; What can I do what API should I use to changing or effecting locking status of database in sqlite if it has some thing for it?
Old 10-10-2011, 01:56 AM   #2
Registered: Nov 2010
Location: Thailand
Distribution: Fedora 12, Ubuntu 10.10
Posts: 166

Rep: Reputation: 29
I'm not fully sure how sqlite is supposed to work, but I'd use mutex for read/write by multiple threads.
Old 10-10-2011, 08:10 AM   #3
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Original Poster
Rep: Reputation: 18
unfortunatley some other processes (like php) wants to read from those databases randomly how can I handle that?
Old 10-10-2011, 09:21 AM   #4
Senior Member
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
When SQLite tries to access a file that is locked by another process, the default behavior is to return SQLITE_BUSY. You can adjust this behavior from C code using the sqlite3_busy_handler() or sqlite3_busy_timeout() API functions.
So in short, if it says busy, deal with it, don't just give up.


Use a full DBMS.

Seems to be the same answer elsewhere

Last edited by Proud; 10-10-2011 at 09:27 AM.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
sqlite triggers after insert problem drj000 Programming 0 05-16-2011 01:31 PM
LXer: Sqlite-Commander - A ncurses based tool to display the records and tables of a sqlite database LXer Syndicated Linux News 0 01-02-2011 08:11 AM
Strange PHP/SQLite problem RattleSn@ke *BSD 1 06-25-2009 04:51 PM
Locking up problem jsrealty2 Ubuntu 3 07-06-2007 03:49 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration