Import Excel data into mysql database

I have an excel file containing about 5000 lines that can be found in one of the mysql databse tables, can anyone give a quick and dirty solution? Thanks

+3
source share
6 answers

Quick and dirty:

Place the calculated column in Excel to generate the insert statement. Then COPY + PASTE all the sentences in the MySQL command interpreter.

Your cell should have this formula:

=CONCATENATE("insert into your table (col1, col2) values (", A1, ", ", B1, ");")

Then copy the formula to all lines and you will have a script.

Other quick and dirty:

Excel ACCESS, " ODBC", MySQL. , ODBC Connection, , .

+6

CSV; " " mySQL, HeidiSQL .

+1

Excel CSV , MySQL, phpMyAdmin.

+1

, CSV. MySQL, CSV PHP explode .

$file = fopen("myfile.csv", "r");
$sql = "INSERT INTO table(field1, field2, field3...";
while(!feof($file))
  {
      $fields = explode(',', fgets($file));
      $sql .= "VALUES("
      foreach($fields as $field)
      {
         $sql .= "$field, ";
      }
      $sql = substr($sql, 0, -2);
      $sql .= "), ";
  }
  $sql = substr($sql, 0, -2);
 fclose($file);
  mysql_query($sql);
+1
0

, .

excel ODBC.

CSV, PHPMyAdmin

CSV, awk script, csv

( )

ODBC? ? PHPMyAdmin? - MySQL?

0

Source: https://habr.com/ru/post/1765172/


All Articles