Several processes writing to an SQLite database at the same time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Several processes writing to an SQLite database at the same time
# 1  
Old 04-07-2011
Several processes writing to an SQLite database at the same time

I have several bash scripts that write to an SQLite3 database at the same time. At some occasion the database returns: SQL error: database is locked.

How would be the best way, to make a process to wait until the data base is 'free' again. I tried:

sqlite3 test.db ".timeout 1000; update....." but it didn't work.

Any ideas, hints would be greatly be appreciated.

Thanks.
# 2  
Old 04-07-2011
I've barely touched sqlite, but if it either
- succeeds and returns 0 or
- makes no change at all and returns an error code
(as I would hope it would), you might try something like this.
Code:
while ! sqlite3 ... ; do
    sleep 1
done

This User Gave Thanks to KenJackson For This Post:
# 3  
Old 04-09-2011
Thanks a lot, that works perfect.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

ruby/SQLite database interface

Hello, I'm not sure this is quite the right place, but there do seem to be allot of posts with folks using ruby to play nicely with databases so I thought I would give it a go. I am starting a long process of developing a database application bases on SQLite and ruby. This will run on various... (1 Reply)
Discussion started by: LMHmedchem
1 Replies

2. Shell Programming and Scripting

Writing a Perl Script that processes multiple files

I want to write a Perl script that manipulates multiple files. In the directory, I have files 250.*chr$.ped where * is from 1 to 1000 and $ is from 1-22 for a total of 22 x 10,000 = 22,000 files. I want to write a script that only manipulates files 250.1chr*.ped where * is from 1 to 22.... (10 Replies)
Discussion started by: evelibertine
10 Replies

3. UNIX for Dummies Questions & Answers

Writing a for loop that processes multiple input files

I would like to write a for loop that does the following: I have a file called X.txt and other files called 1.txt,2.txt, .....,1000.txt. I want to substitute the 6th column of the file X.txt with 1.txt and store the output as X.1. Then I want to do the same with X.txt and 2.txt and store the... (1 Reply)
Discussion started by: evelibertine
1 Replies

4. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

5. Programming

PHP Script Not Writing Bankfee To Database

The attached file, credits.php, is part of our new (experimental) banking / credits system for this site. I added a field bankfee in credits_transactions but it is not writing to the database (no PHP error). Can someone take a look at the attached PHP file and see if they can find out why... (4 Replies)
Discussion started by: Neo
4 Replies

6. AIX

estimating memory usage by database processes

Hi Guys, I wonder what would be the best way to determine how much memory is in use on any given time by the database processes. I thought about using ipcs -m command but I wonder if there any better way to determine this. Thanks. Harby. (2 Replies)
Discussion started by: hariza
2 Replies

7. Shell Programming and Scripting

Multiple processes writing on the same file simultaneously

Hi All, I have encountered a problem,please help me. I have a script in which multiple processes are writing on to the same file . How should I stop this , I mean lock mechanism can be implemented or we can write the at different files and then concatenate the files. What would be a better... (1 Reply)
Discussion started by: Sayantan
1 Replies

8. Shell Programming and Scripting

writing script file for database

how to disable a constraint type of a field (present in diffrent tables) in the database unix a unix script file.. (3 Replies)
Discussion started by: shaksing
3 Replies

9. HP-UX

sqlite database in HP-UX vs Linux

Hi everybody, We have a cgi application which accesses sqlite database. It works fine in Linux environment but the same code doesn't enter data into the database when done in HP-UX environment. Should the codes vary depending on whether it is Linux or HP-UX. Regards Ruma (1 Reply)
Discussion started by: perlprg
1 Replies

10. UNIX for Advanced & Expert Users

writing database tables into a file in unix

I want to collect the database tables(Ex: Emp,Sal,Bonus...etc) in a file & give this file at the command prompt, when prompted for the tables list at command prompt. How can i do that ? Ex:- Import jason/jason1 tables=emp,sal,bonus log=j1.log i want to change this into Ex:- Import... (3 Replies)
Discussion started by: dreams5617
3 Replies
Login or Register to Ask a Question