I wrote a big sql script that creates a CSV file. I want to call cronjob every day to create a new CSV file and make it available on the website.
Say, for example, I store my file in the /home/sites/example.com/www/files/backup.csv folder
and my SQL
SELECT * INTO OUTFILE '/home/sites/example.com/www/files/backup.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM ( ....
MySQL gives me an error when a file already exists
The file '/home/sites/example.com/www/files/backup.csv' already exists
Is there a way to get MySQL to overwrite the file?
I could have PHP detect if the file exists and delete it before creating it again, but it would be more concise if I can do it directly in MySQL.
sql php mysql into-outfile
Derek Organ Jun 06 '09 at 21:50 2009-06-06 21:50
source share