Skip navigation links

MySQL Forums :: Events (Job Scheduler) :: event to export table to csv log file every day at midnight


Advanced Search

event to export table to csv log file every day at midnight
Posted by: Darren White ()
Date: March 07, 2012 07:08AM

ok I have no experience of Events or the Mysql command line (I've used workbench).

I have some log tables being generated using triggers.

Now I want to export these tables to a csv files and empty these tables once a day.

I have some code for generating the log files which works:

SELECT @myCommand := concat(
"SELECT * into OUTFILE 'C:/logs/log_01_",
DATE_FORMAT(now(),'%Y_%m_%d_%h_%i_%s'), ".csv'
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n'
FROM log_streamer_01");
PREPARE stmt FROM @myCommand;
EXECUTE stmt;

now I want to have a schedule that executes this every day at 00:00:00 and then empties the table (ready to be filled again over the next day).

I would really appreciate some help to get me started quickly here. :-)



Edited 1 time(s). Last edit at 03/07/2012 07:36AM by Darren White.

Options: ReplyQuote


Subject Views Written By Posted
event to export table to csv log file every day at midnight 3988 Darren White 03/07/2012 07:08AM
Re: event to export table to csv log file every day at midnight 1927 Darren White 03/07/2012 08:22AM
Re: event to export table to csv log file every day at midnight 1876 Darren White 03/07/2012 08:40AM
Re: event to export table to csv log file every day at midnight 1379 Darren White 03/07/2012 11:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.