Business data from the company headquarters, background data settings are exported by day CSV, but the analysis of the business needs to see the entire time trend, Excel has been dead, only on MySQL, with SQL statement query. In fact, the load data local infile can be done, the trouble is that there are too many table header fields, and may change, do not want to write a script every time first create table structure and re-guide data. Is there any way to automatically handle the header?
First, using Nevicat or Workbench
There are options for importing data that can help automatically detect data types and generate headers.
After testing, using the graphical interface to import data, the speed is very slow, this scheme does not work.
Second, write the command line interactive prompt script
The Python script reads the CSV header file, then generates the SQL statement based on the field name and the first row of data, and then even MySQL. In short, it's a python automation. This program can, need to write code.
Iii. Comprehensive Law
Read only the first three data in the table, save the file, and then workbench the import, generate the table data, and then load on the local data infile.
MySQL Import millions Data schema summary