Mysql script
I have a linux script that wirtes a csv file for my mysql database table. Now its writing the csv file even if the tbale is empty? is their a way to check to see if theirs data first, if so write the file if not kill this part of the script?
Script [script] select * into outfile '/tmp/file2' FIELDS TERMINATED BY ';' LINES TERMINATED BY '\N' FROM DIRECT_REFERRAL [/script] |
Using PHP you could do something like this:
PHP Code:
|
ok
Hers is my full bin bash script. I only want to run the this script if their is data in my table? if not do nothing?
thanks #!/bin/bash date=`date +%Y%m%d%H%M%S` file="ReferralAuth$date.txt" cat /usr/etc/extractreferral.sql | sed -e "s/file/$file/g" |/usr/bin/mysql -u root XXXXX extractreferral.sql SELECT * INTO OUTFILE '/tmp/file' FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' FROM Referral_Authorization |
All times are GMT -5. The time now is 06:13 AM. |