28 lines
551 B
Plaintext
28 lines
551 B
Plaintext
openDatabase() {
|
|
if [ ! -d "$tempdir" ]
|
|
then
|
|
mkdir -p "$tempdir"
|
|
fi
|
|
rm -f "$tempdir"/sqlite.{in,out}
|
|
mkfifo "$tempdir"/sqlite.{in,out}
|
|
if [ ! -f "$database" ]
|
|
then
|
|
if [ ! -d "${database%/*}" ]
|
|
then
|
|
mkdir -p "${database%/*}"
|
|
fi
|
|
sqlite3 "$database" < $schema
|
|
fi
|
|
sqlite3 -bail "$database" \
|
|
< "$tempdir/sqlite.in" \
|
|
> "$tempdir/sqlite.out" &
|
|
exec 3> "$tempdir"/sqlite.in
|
|
exec 4< "$tempdir"/sqlite.out
|
|
if (( debug > 2 ))
|
|
then
|
|
exec 5>&3
|
|
exec 3> >(tee -a $tempdir/debug.log >&5)
|
|
fi
|
|
echo 'PRAGMA foreign_keys = ON;' >&3
|
|
}
|