I need to let users import huge csv files varied between 200k - 1.5m lines. For this I use LOAD DATA INFILE
which is the fastest way to import those files. Thing is however that I can't check the user input, I have solved this by using a trigger on a table. My table structure is as following: (narrowed down to make it more readable):
tbl_debtor: debtor_id (AI), debtor
tbl_debtor_tmp: debtor
tbl_debtor_err: error
Now the (before insert) trigger is on tbl_debtor_tmp
where users can literally import anything. In that trigger I check their user input, if okay I'll do a insert on tbl_debtor
. If the user input is not okay I write to tbl_debtor_err
. After the import is done I'll do a DELETE FROM tbl_debtor_tmp
My question here is, is there a more efficient way? I have about 20 of those table structures which I think is alot.