简体   繁体   中英

How to import Data from CSV file to MySQL database without using LOAD DATA INFILE Syntax?

如何不使用LOAD DATA INFILE语法将数据从CSV文件导入MySQL数据库?

Most pedestrian way: open the .csv as text file, parse/split each line into a list of values, feed them to a prepared command "INSERT INTO table (field, ..) VALUES( ?, ...)"

Still with loop: use ADO/OleDb to open the .csv as table, feed each row's data to the statement.

Nice method (if doable): use ADO/OleDb to access the .csv and execute a "SELECT/INSERT INTO" statement specifying the MySQL database as external (ODBC).

A schema.ini file for the .csv is needed for the the last two approaches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM