0

The below event is giving me a empty file with no backup data.

DELIMITER $$
CREATE DEFINER=`root`@`localhost` EVENT `Backup` 
ON SCHEDULE EVERY 1 minute 
STARTS '2017-12-11 18:09:00' ON COMPLETION PRESERVE ENABLE 
DO 
BEGIN

SET @sql_text = CONCAT("SELECT * FROM dataproject.newbookings INTO OUTFILE '/C:/Users/Ayushkumar/Desktop/backup/", DATE_FORMAT( NOW(), %Y%m%d'),"backup1.csv'");
PREPARE s1 FROM @sql_text;
EXECUTE s1;
DEALLOCATE PREPARE s1;
END $$ DELIMITER;
y.luis.rojo
  • 1,794
  • 4
  • 22
  • 41
Neo
  • 13
  • 5
  • Thanks for sharing a status report. Was there a *question*? (A couple of comments: the forward slash `/` before the `C:` looks like an odd filename. And when you execute the generated SQL statement from a different client, like the MySQL client, what is the result? And when you run it a second time, what happens? (I believe the `INTO OUTFILE` option requires that the file not already exist. Looks like the date format is going to generate the same filename 1440 times. – spencer7593 Dec 12 '17 at 00:54
  • The event script is giving me a empty file with no backup data. – Neo Dec 12 '17 at 00:57
  • You are reporting the status of your current deveiopment efforts. And that is *not* a question. – spencer7593 Dec 12 '17 at 00:59
  • I removed the forward slash/ and ran the following coomand on mysql workbench:- Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%Y%m%d'),"backup2.csv'' at line 1 – Neo Dec 12 '17 at 01:04

0 Answers0