If you ask if it can be used in a script; you can do something like this with php:
<?php $mysqli = new mysqli("host", "user", "pwd", "db"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $sql = "CREATE TABLE number1 (id INT PRIMARY KEY auto_increment,data TEXT)"; if ($result = $mysqli->query($sql)) { } else { printf("<br>%s",$mysqli->error); } $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $filename = "data.csv"; $sql = "LOAD DATA LOCAL INFILE '$host$uri$filename' INTO TABLE number1"; if ($result = $mysqli->query($sql)) { } else { printf("<br>%s",$mysqli->error); } // Close the DB connection $mysqli->close(); exit; %>
If the file is in the same folder as the script, just use $ filename a instead of $ host $ uri $ filename. I compiled this quickly from several scripts that I use, sorry if it doesn't work without debugging, but it should be pretty close. This requires mysqli.
source share