diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2019-11-11 17:38:05 +0100 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2019-11-11 17:38:05 +0100 |
commit | e93dfe5f60e86d08b5bb4c64d1ce01f2fd1be4ae (patch) | |
tree | 1f7289908d9f318436921c35e5c786f06eccbade /server/lib/ogfunctions.sh | |
parent | 83f20d1889a73f0088f61b4014c80fb4248a21be (diff) |
#839: Use global function to execute commands in the database.
Diffstat (limited to 'server/lib/ogfunctions.sh')
-rwxr-xr-x | server/lib/ogfunctions.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/lib/ogfunctions.sh b/server/lib/ogfunctions.sh index 34b2ab7b..4b61166b 100755 --- a/server/lib/ogfunctions.sh +++ b/server/lib/ogfunctions.sh @@ -68,6 +68,22 @@ function stop() { _service stop "$1" } +# Execute database operation. +function dbexec () { + MYCNF=$(mktemp) + trap "rm -f $MYCNF" 0 1 2 3 6 9 15 + touch $MYCNF + chmod 600 $MYCNF + cat << EOT > $MYCNF +[client] +user=$USUARIO +password=$PASSWORD +EOT + mysql --defaults-extra-file="$MYCNF" -D "$CATALOG" -s -N -e "$1" || \ + raiseError access "Cannot access the databse" + rm -f "$MYCNF" +} + ### Meta-functions and private functions. @@ -94,3 +110,4 @@ function _service() { raiseError notfound "Service $SERVICE" fi } + |