Convert CSV to SQL insert queries tool


Background: There were some hosting companies (typically the free ones) which will not allow importing of MySQL database or tables to the database server. If you are working with a localhost MySQL database such as XAMPP, your database table can be converted to an equivalent .csv file and then upload the csv file using this tool to generate MySQL INSERT queries. To convert your MySQL database table to CSV file follow the procedures below very carefully:

Step 1: Login to XAMPP phpmyadmin.

Step 2: Click the database you need.

Step 3: Click the table where you need to export to hosting database server.

Step 4: Click "Export".

Step 5: Under export click "CSV".

Step 6: Under options, set "Fields terminated by:" to semi colon (;)

Step 7: Under options, change "Fields enclosed by:" to blank.

Step 8: Under options, change "Fields escaped by:" to blank.

Step 9: Leave other options at default (Lines terminated by: AUTO and Replace Null by: NULL)

Step 10: Check "Put fields names in the first row".

Step 11: Check "Save as file".

Step 12: Click "Go".

Step 13: Find the downloaded CSV file in your computer and then right click on the csv file and open it with notepad or gedit. The CSV content should be formatted like:

csv output format

Step 14: You can now upload your CSV file using the tool below to convert that to MySQL insert queries. In the "Name of the MySQL table that this data to be inserted:", enter exactly the name of the database table describing the CSV data. This should correspond to the MySQL table name in your hosting server.

Step 17: Click Convert to SQL query.

Step 18: Select the results (ONLY with blue font below) and copy-paste it to the SQL query window in the hosting (not localhost) phpmyadmin. See screenshot:

Insert Statements in MySQL
Important: Create the MySQL table first before inputting the query below to your hosting phpmyadmin.

Maximum allowable CSV File upload size: 50kB




Name of the MySQL table that this data to be inserted:


Type the captcha below (sorry but this application can be abused by bots so we need to make sure you are a human, thanks for understanding):





Related documentation about the development of this tool: http://www.codewalkers.com/c/a/Database-Code/Converting-CSV-Files-to-MySQL-Insert-Queries-Using-PHP/
Note: If the last data row seems to be missing in the Insert statement, make sure there are no spaces after that last line in your .csv file.

Download source code




Link To This Tool
1. Click inside the codebox
2. Right-Click then Copy
3. Paste the HTML code into your webpage
codebox