Pink
Pink

Reputation: 161

Import multiple CSV files into mysql

I have about 28 csv files and I need to import this into database as 28 tables. I tried many things but just couldn't find a way.

Upvotes: 1

Views: 5332

Answers (2)

Argimko
Argimko

Reputation: 624

It's a good solution for Windows-users. Just create a text file "import.bat" with code, after that run it.

@ECHO off
FOR %%I In (db\*.sql) DO mysqlimport.exe --local -uroot -proot vipamoda %%I
PAUSE

More complex code which importing first SQL-structure, then import TXT-data:

@ECHO off
FOR %%I IN (db\*.sql) DO (
    mysql.exe -uroot -proot vipamoda < %%~dpnI.sql
    mysqlimport.exe --local -uroot -proot vipamoda %%~dpnI.txt
)
PAUSE

And dump code for this import code is:

mysqldump.exe --compact --add-drop-table --tab=db -uroot -proot vipamoda

Upvotes: 1

user319198
user319198

Reputation:

You can link MYSQL directly to it and upload the information using the following SQL syntax.

load data local infile 'uniq.csv' into table tblUniq
fields terminated by ','
enclosed by '"'
lines terminated by '\n'

Read more here : LOAD DATA INFILE

Import CSV file directly into MySQL

Upvotes: 1

Related Questions