mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-07-06 04:51:52 -07:00
RACK911LABS.COM: safer mysql/pgsql query
This commit is contained in:
parent
4c751ab693
commit
b5874764a7
1 changed files with 8 additions and 2 deletions
10
func/db.sh
10
func/db.sh
|
@ -47,7 +47,10 @@ mysql_connect() {
|
|||
}
|
||||
|
||||
mysql_query() {
|
||||
mysql --defaults-file=$mycnf -e "$1" 2>/dev/null
|
||||
sql_tmp=$(mktemp)
|
||||
echo "$1" > $sql_tmp
|
||||
mysql --defaults-file=$mycnf < "$sql_tmp" 2>/dev/null
|
||||
rm -f "$sql_tmp"
|
||||
}
|
||||
|
||||
mysql_dump() {
|
||||
|
@ -89,7 +92,10 @@ psql_connect() {
|
|||
}
|
||||
|
||||
psql_query() {
|
||||
psql -h $HOST -U $USER -c "$1" 2>/dev/null
|
||||
sql_tmp=$(mktemp)
|
||||
echo "$1" > $sql_tmp
|
||||
psql -h $HOST -U $USER -f "$sql_tmp" 2>/dev/null
|
||||
rm -f $sql_tmp
|
||||
}
|
||||
|
||||
psql_dump() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue