Add timeout to sqlite3 queries
This commit is contained in:
parent
c0728d2969
commit
4e6d4f396b
|
@ -11,26 +11,26 @@ source ./config/analyzer.conf
|
||||||
DATABASE=${DATABASE:-"./var/db.sqlite"}
|
DATABASE=${DATABASE:-"./var/db.sqlite"}
|
||||||
|
|
||||||
get_location_id() {
|
get_location_id() {
|
||||||
sqlite3 $DATABASE "SELECT location_id FROM location WHERE latitude=$1 AND longitude=$2"
|
sqlite3 -cmd ".timeout 1000" $DATABASE "SELECT location_id FROM location WHERE latitude=$1 AND longitude=$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_taxon_id() {
|
get_taxon_id() {
|
||||||
sqlite3 $DATABASE "SELECT taxon_id FROM taxon WHERE scientific_name='$1'"
|
sqlite3 -cmd ".timeout 1000" $DATABASE "SELECT taxon_id FROM taxon WHERE scientific_name='$1'"
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_taxon() {
|
insert_taxon() {
|
||||||
sqlite3 $DATABASE "INSERT INTO taxon (scientific_name, common_name) VALUES ('$1', '$2')"
|
sqlite3 -cmd ".timeout 1000" $DATABASE "INSERT INTO taxon (scientific_name, common_name) VALUES (\"$1\", \"$2\")"
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_location() {
|
insert_location() {
|
||||||
sqlite3 $DATABASE "INSERT INTO location (latitude, longitude) VALUES ($1, $2)"
|
sqlite3 -cmd ".timeout 1000" $DATABASE "INSERT INTO location (latitude, longitude) VALUES ($1, $2)"
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_observation() {
|
insert_observation() {
|
||||||
sqlite3 $DATABASE "INSERT INTO observation (audio_file, start, end, taxon_id, location_id, confidence, date) VALUES ('$1', '$2', '$3', '$4', '$5', '$6', '$7')"
|
sqlite3 -cmd ".timeout 1000" $DATABASE "INSERT INTO observation (audio_file, start, end, taxon_id, location_id, confidence, date) VALUES ('$1', '$2', '$3', '$4', '$5', '$6', '$7')"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the observation already exists in the database
|
# Check if the observation already exists in the database
|
||||||
observation_exists() {
|
observation_exists() {
|
||||||
sqlite3 $DATABASE "SELECT EXISTS(SELECT observation_id FROM observation WHERE audio_file='$1' AND start='$2' AND end='$3' AND taxon_id='$4' AND location_id='$5')"
|
sqlite3 -cmd ".timeout 1000" $DATABASE "SELECT EXISTS(SELECT observation_id FROM observation WHERE audio_file='$1' AND start='$2' AND end='$3' AND taxon_id='$4' AND location_id='$5')"
|
||||||
}
|
}
|
Loading…
Reference in New Issue