Re: bash powered MySQL Queries

2005-01-31 Thread beacker
I just wanted to know what would be the easiest way to retrieve simple data 
from a MySQL database from a bash script.

 Easiest way I've used to do it is:

mysql EOQ
select count(1) from tables;
EOQ

Which allows you to feed random queries to mysql from a bash script.
Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bash powered MySQL Queries

2005-01-31 Thread andy thomas
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]



Re: bash powered MySQL Queries

2005-01-31 Thread Andy
Thank you all for your replies.


I think that ShellSQL is really the thing I am looking for.


With kind regards


Andy

On Sun January 30 2005 23:50, 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.

 With kind regards



 Andy


 --
 ---
 Registered Linux user number 379093
 ---
 --

-- 
---
Registered Linux user number 379093
---

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bash powered MySQL Queries

2005-01-31 Thread Jason Martin
On Mon, Jan 31, 2005 at 06:57:58PM +, Edward Macnaghten wrote:
 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.
The mysql --batch option should take care of that for you.

-Jason Martin
-- 
If your attack is going well, then it's an ambush..
This message is PGP/MIME signed.


pgpGbq3SC6aXz.pgp
Description: PGP signature


Re: bash powered MySQL Queries

2005-01-31 Thread Edward Macnaghten
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]


Re: bash powered MySQL Queries

2005-01-30 Thread Edward Macnaghten
Funny you should mention that
May I guide you to my recent announcment of ShellSQL 0.7 - web page at 
http://www.edlsystems.com/shellsql - a utility to do just as you want (I 
think) released under GPL.

It must be good - I wrote it myself :-)
Yours
Eddy
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.

With kind regards

Andy


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: bash powered MySQL Queries

2005-01-30 Thread Kevin A. Burton
Edward Macnaghten wrote:
Funny you should mention that
May I guide you to my recent announcment of ShellSQL 0.7 - web page at 
http://www.edlsystems.com/shellsql - a utility to do just as you want 
(I think) released under GPL.

It must be good - I wrote it myself :-)
SELECT * FROM /dev/zero INTO OUTFILE /dev/null
:)
Seems like a cool project though.
Kevin
--
Use Rojo (RSS/Atom aggregator).  Visit http://rojo.com. Ask me for an 
invite!  Also see irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html
If you're interested in RSS, Weblogs, Social Networking, etc... then you 
should work for Rojo!  If you recommend someone and we hire them you'll 
get a free iPod!
   
Kevin A. Burton, Location - San Francisco, CA
  AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]