LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

Rep: Reputation: 17
sqlite locking problem in C programming


hello
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
cnxsoft
Member
 
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
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Original Poster
Rep: Reputation: 17
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
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
http://www.sqlite.org/faq.html#q5
Quote:
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.

Or

Use a full DBMS.

Seems to be the same answer elsewhere http://stackoverflow.com/questions/1...iple-processes

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


Reply


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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:49 AM.

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