themactep.com

A home of miscellaneous projects by Paul Philippov.

Notes

How to import data from CSV files into MySQL DB

Create a file with SQL commands

# csv2mysql.sql

LOAD DATA LOCAL INFILE "/path/to/categories.csv"
  INTO TABLE categories
  FIELDS TERMINATED BY "," ENCLOSED BY "\""
  LINES TERMINATED BY "\r\n";

LOAD DATA LOCAL INFILE "/path/to/items.csv"
  INTO TABLE items
  FIELDS TERMINATED BY "," ENCLOSED BY "\""
  LINES TERMINATED BY "\r\n";

then feed it into MySQL client against your database

sudo mysql mydatabase < csv2mysql.sql