Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mysqlquery {
- local dbserver='localhost'
- local dbuser='user'
- local dbpass='pass'
- local db='mydb'
- mysql -h "$dbserver" -u "$dbuser" -p "$dbpass" --skip-column-names --raw -e "$*" "$db"
- if [ $? -ne 0 ]; then
- return 1
- fi
- }
- for XY in $(mysqlquery "select XY from ABC where DEF = 123" 2>/dev/null);do
- dosomethingwith $XY
- done
- if mysqlquery "select XY from ABC where DEF = 123" 2>/dev/null; then
- echo true
- fi
- function mysqlquery {
- local dbserver='localhost'
- local dbuser='user'
- local dbpass='pass'
- local db='mydb'
- result=$(mysql -h "$dbserver" -u "$dbuser" -p "$dbpass" -e "$*" "$db" 2>/dev/null)
- if [ $? -ne 0 -o -z "$result" ]; then
- return 1
- fi
- }
- result=$(mysqlquery "select XY from ABC where DEF = 123" 2>/dev/null)
- for XY in $result;do
- dosomethingwith $XY
- done
- if mysqlquery "select XY from ABC where DEF = 123" 2>/dev/null; then
- echo true
- fi
Add Comment
Please, Sign In to add comment