Forgive me for blowing my own trumpet here.
The advantage with ShellSQL over this method is....
1 - The output is not cluttered with headers, and a means exist to easily separate fields when there is more than one column or row in the query.
2 - The connection is persistant, whereas running "mysql" for each command will open and close a connection with all the overhead that comes with that. ShellSQL also enables you to do transactions "begin" and "commit" at the beginning and end of the script.
Eddy
andy thomas wrote:
On Sun, 30 Jan 2005, Andy wrote:
Hi all
I just wanted to know what would be the easiest way to retrieve simple data from a MySQL database from a bash script.
I do this a lot - just construct the query and dump it into a file from within the script, eg:
echo "select * from widgets where colour = 'red';" > /tmp/query
Then pipe the query into the mysql command line client and the result is echoed to stdin:
$RESULT=`mysql -u user -ppassword widget_sales < /tmp/query`
and the variable $RESULT contains the result of your query.
Andy
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]