I have a case to import data into mysql automatically every 6pm. data to be imported is "data.txt".
I created in mysql like this:
CREATE EVENT EVENT_NAME
ON SCHEDULE EVERY '18: 00:00 'DAY
DO
LOAD DATA LOCAL INFILE 'd :/ data.txt'
INTO TABLE table_name
FIELDS terminated BY ','
LINES terminated BY '\ n'
(atribut1, atribut2, atribut3);
if i just write like this
LOAD DATA LOCAL INFILE 'd :/ data.txt'
INTO TABLE table_name
FIELDS terminated BY ','
LINES terminated BY '\ n'
(atribut1, atribut2, atribut3);
the query was successfully executed
but if i write the code like a fist code instead there is an error "LOAD DATA is not allowed in stored procedures". is it really like that? if it's like that how do i to handle such cases? thanks in advance sorry for my bad english
Indeed, you are out of luck.
You will need to resort to an external mechanism in order to automate this import (such as a cron job).
You can submit arbitrary statements from outside MySQL by calling the mysql
command-line client like this:
shell > mysql [options] -D [database] -e "LOAD DATA INFILE..."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With