create, open and close database
This commit is contained in:
parent
62b3b2ff29
commit
eaff01d689
36
atom
36
atom
@ -28,7 +28,9 @@ declare -A \
|
|||||||
}
|
}
|
||||||
|
|
||||||
DOCDIR=./doc
|
DOCDIR=./doc
|
||||||
|
SHAREDIR=./share
|
||||||
exampleconf=$DOCDIR/example.cfg
|
exampleconf=$DOCDIR/example.cfg
|
||||||
|
schema=$SHAREDIR/schema.sql
|
||||||
|
|
||||||
#parse arguments
|
#parse arguments
|
||||||
#parse config
|
#parse config
|
||||||
@ -59,6 +61,9 @@ getConfigGeneral() {
|
|||||||
'temporary-directory')
|
'temporary-directory')
|
||||||
tempdir="$value"
|
tempdir="$value"
|
||||||
;;
|
;;
|
||||||
|
'database')
|
||||||
|
database="$value"
|
||||||
|
;;
|
||||||
debug)
|
debug)
|
||||||
#unimplemented
|
#unimplemented
|
||||||
;;
|
;;
|
||||||
@ -197,6 +202,33 @@ getConfig() {
|
|||||||
|
|
||||||
#check sanity
|
#check sanity
|
||||||
|
|
||||||
|
openDatabase() {
|
||||||
|
if [ ! -d "$tempdir" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$tempdir"
|
||||||
|
fi
|
||||||
|
mkfifo "$tempdir"/sqlite.{in,out}
|
||||||
|
if [ ! -f "$database" ]
|
||||||
|
then
|
||||||
|
if [ ! -d "${database%/*}" ]
|
||||||
|
then
|
||||||
|
mkdir -p "${database%/*}"
|
||||||
|
fi
|
||||||
|
sqlite3 "$database" < $schema
|
||||||
|
fi
|
||||||
|
sqlite3 -line "$database" \
|
||||||
|
< "$tempdir/sqlite.in" \
|
||||||
|
> "$tempdir/sqlite.out" &
|
||||||
|
exec 3> "$tempdir"/sqlite.in
|
||||||
|
exec 4< "$tempdir"/sqlite.out
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDatabase() {
|
||||||
|
exec 3>&-
|
||||||
|
exec 4<&-
|
||||||
|
rm "$tempdir"/sqlite.{in,out}
|
||||||
|
}
|
||||||
|
|
||||||
getFiles() {
|
getFiles() {
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
@ -328,4 +360,8 @@ echo "|Copied mime-type|${destinationcopymime[$destination]//\|/
|
|||||||
done
|
done
|
||||||
}|column -t -s'|' -n
|
}|column -t -s'|' -n
|
||||||
|
|
||||||
|
openDatabase
|
||||||
|
|
||||||
|
closeDatabase
|
||||||
|
|
||||||
# vim:set ts=8 sw=8:
|
# vim:set ts=8 sw=8:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user