coren has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/85002


Change subject: Tool Labs: tweak sql utility
......................................................................

Tool Labs: tweak sql utility

So that it accepts an sql statement(s) on the command line
like its toolserver equivalent.

Change-Id: I6e67aef395abafb7ab83bae834783a8f42c6d76d
---
M modules/toollabs/files/sql
1 file changed, 8 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/02/85002/1

diff --git a/modules/toollabs/files/sql b/modules/toollabs/files/sql
index de5884c..25eaaac 100755
--- a/modules/toollabs/files/sql
+++ b/modules/toollabs/files/sql
@@ -17,7 +17,7 @@
 fi
 
 if [ "$1" = "-h" ] || [ "$1" == "--help" ];then
-       echo "Usage: sql <database>[_p] [-vh]"
+    echo "Usage: sql <database>[_p] [-vh] [command(s)]"
        echo
        echo "This tool allows you to easily open a connection to sql database 
without having to provide the credentials or a database host server"
        echo "Example: sql frwiki_p"
@@ -99,7 +99,7 @@
        # lookup from hosts
        if [ `echo "$1" | grep -cE '_p$'` -lt 1 ];then
             Log "Invalid database name, recursive attempt suffixing _p..."
-            if (sql $1_p ${*:2});then
+            if ($0 $1_p ${*:2});then
                     exit 0
             fi
              echo "Make sure to ask for a db in format of <wiki>_p"
@@ -117,5 +117,10 @@
    ;;
 esac
 
+shift
 Log "Connecting to $server"
-mysql $param -h $server $db ${*:2}
+if [ $# -lt 1 ]; then
+  exec mysql $param -h $server $db "$@"
+else
+  echo "$@" | mysql $param -h $server $db
+fi

-- 
To view, visit https://gerrit.wikimedia.org/r/85002
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e67aef395abafb7ab83bae834783a8f42c6d76d
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: coren <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to