add possibility to run db-statement on connectdb
This commit is contained in:
parent
797e4da5d1
commit
255fbf0907
1 changed files with 17 additions and 4 deletions
19
functions.sh
19
functions.sh
|
@ -1179,18 +1179,31 @@ function connectdb () {
|
|||
getdbcreds_cnf $2
|
||||
;;
|
||||
*)
|
||||
echo "wrong argument"
|
||||
echo "wrong argument" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
cat << EOF
|
||||
cat << EOF >&2
|
||||
connect to ${DB_HOST}:${DB_PORT}/${DB_NAME}
|
||||
with user: ${DB_USER}
|
||||
and passwd: ${DB_PWD}
|
||||
and passwd: ${DB_PWD:+********}
|
||||
EOF
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
case $1 in
|
||||
-c)
|
||||
shift
|
||||
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME -c "$@"
|
||||
;;
|
||||
*)
|
||||
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME $@
|
||||
;;
|
||||
esac
|
||||
else
|
||||
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue