Batch Load text files to MySQL

Piglette
Lounger
Posts: 35
Joined: 20 Feb 2010, 05:05

Batch Load text files to MySQL

Post by Piglette »

Hello Hans:

I have a process that I need to run once a week. Loading many pipe-delimited text files to preexisting MySQL tables. Windows 7

Is there a batch way of doing this using VBS (for example)?

Thanks

Lukas van der Walde

User avatar
HansV
Administrator
Posts: 78589
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Batch Load text files to MySQL

Post by HansV »

I have no experience with MySQL. Perhaps Import data from txt file or excel to Mysql vbscript will give you some ideas. You'll have to adapt the code of course.
Best wishes,
Hans

Piglette
Lounger
Posts: 35
Joined: 20 Feb 2010, 05:05

Re: Batch Load text files to MySQL

Post by Piglette »

Hans:

Thanks very much! That looks promising.

Lukas

User avatar
Jezza
5StarLounger
Posts: 847
Joined: 24 Jan 2010, 06:35
Location: A Magic Forest in Deepest, Darkest, Kent

Re: Batch Load text files to MySQL

Post by Jezza »

Piglette wrote:Hello Hans:

I have a process that I need to run once a week. Loading many pipe-delimited text files to preexisting MySQL tables. Windows 7

Is there a batch way of doing this using VBS (for example)?

Thanks

Lukas van der Walde
Hi Lukas, this is very possible and must assume you have the correct permissions on the Windows 7 machine and the correct account that has insert permissions on the My SQL database. The small issue you will have is the batch file will show the username and password as clear text in its content: Use it like this

Code: Select all

set database_name=db_name
mysql –u root --password=pass --database %database_name% < c:/myInsertFile/sql_insert.sql
I hope that helps
Jerry
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it