LOAD DATA not allowed in stored procedures

I have a case to import data into mysql automatically every 6 pm. the imported data 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 request was successfully completed

but if I write code that resembles fist code, instead the error "LOAD DATA is not allowed in stored procedures" occurs. is it really so if so, how can I handle such cases? thank you in advance sorry for my bad english

+4
source share
1 answer

Indeed, you are out of luck .

You will need to turn to an external mechanism to automate this import (for example, the cron job).

You can send arbitrary statements from external MySQL by invoking the mysql command-line client as follows:

  shell> mysql [options] -D [database] -e "LOAD DATA INFILE ..."
+2
source

Source: https://habr.com/ru/post/1487857/


All Articles