tags:

views:

908

answers:

3

Now I know how one can execute mysql queries \ commands from bash :

mysql -u[user] -p[pass] -e "[mysql commands]"

or

mysql -u[user] -p[pass] `<<`QUERY_INPUT

[mysql commands]

QUERY_INPUT

My question is : How can I capture how many rows where affected by the query? I tried doing:

variable='`mysql -u[user] -p[pass] -e "[mysql commands]"`'

It does execute the command but it does not return the number of affected rows.

Thanks

+1  A: 

I might have answered myself the question, been looking at the parameters, and aparently using "-v -v -v" as parameters to the mysql command forces it to be more verbose and it spits out how many rows where affected.

theBlinker
+3  A: 

Put

SELECT ROW_COUNT();

as the last statement in your batch and parse the output

Ken Keenan
Yes, this does work, and is more elegant and easier to parse the output. Thank you it was very helpful.
theBlinker
A: 

Thanks theBlinker, this -v -v -v helped me lot

senthil