Database batch write judgment problems I do a function is an order import function, the data in the xls is imported into mysql, each time about 1000. the problem is that each record has an encoding. First, check whether the encoding system has been set up and imported, if the entire batch is not imported into the system, what should I do ?? ------ Solution ------- database batch write judgment
My function is an order import function. I will import the data in xls to mysql, with about 1000 entries each time.
The problem is that each record has an encoding. First, check whether the encoding system has been set up and imported, if the entire batch is not imported into the system, what should I do ??
------ Solution --------------------
I don't understand. each record has a single encoding, but this encoding is not properly configured. Why can't I import the entire batch? Isn't this one?
If the one I want cannot be imported, do the following:
Read the 1000 pieces of data from the XLS file, read the encoding table from the database, create an array using the encoding as the primary key, and then read your 1000 pieces of data cyclically, each time you use the encoding of this data to find whether the encoding array exists. if it does not exist, it is skipped. if it exists, it is saved to the database. Of course, you can write SQL statements and save them at the last time.
------ Solution --------------------
It's nothing to look!
It is easy to implement.
First check whether the encoding exists (select)
Insert based on the result)
Obviously, your system uses a foreign key (it is purely for yourself)
In fact, direct insertion does not matter. it is not an error or the insertion is invalid.