auto import csv

[expired user #9179]'s profile image [expired user #9179] posted 9 years ago in General Permalink
Hello,
i´m trying to insert an auto import from a csv file but i have no idea how to do this.
The autorefresh is no problem.
My csv file will be renewed every 30minutes so i have to import it in that time.
Am i forced to create a script?
I had HeidiSQL some time ago in school but I´m not skilled in it.
ansgar's profile image ansgar posted 9 years ago Permalink
You can import a CSV file in Tools > Import CSV file.

There is no way to automate that in HeidiSQL, you need to click the buttons manually.

If you want to automate/schedule that, you can download the MySQL Utilities and use mysqldbimport.exe

You need the VC++ redistributables from Microsoft if you don't have them:
http://www.microsoft.com/de-de/download/details.aspx?id=40784
... and then the MySQL utilities:
http://dev.mysql.com/downloads/utilities/

After installing, you have several .exe files in C:\Program Files (x86)\MySQL\MySQL Utilities\ .
Start over by running cmd.exe and run the following command (adapt to your paths):
C:\Program Files (x86)\MySQL\MySQL Utilities\mysqldbimport.exe --server=user:pass@host:port:socket --format=csv c:\path\to\yourtextfile.csv


Tweak that command line until it runs and then run taskschd.msc and create a scheduled task, with the above command line.
[expired user #9179]'s profile image [expired user #9179] posted 9 years ago Permalink
Thanks for your answer!
I can connect to HeidiSQL so far. But with this command i creat a new DB with ne name "none". He throws an error that "none" allready exists.
In HeidiSQL i can see the DB "none" but it has no csv files in it.
Maybe my command line has some mistakes. Could you give me a piece of advice?
2 attachment(s):
  • DB-einstellungen
  • import-DB
[expired user #9179]'s profile image [expired user #9179] posted 9 years ago Permalink
OK, i skipped the DB create.
No Errors, but i can´t find the data from the csv file.
I expteced it in "none" but there is no data.
1 attachment(s):
  • Datenbank
ansgar's profile image ansgar posted 9 years ago Permalink
Can you pass the name of an existing table to mysqlimportdb.exe?
[expired user #9179]'s profile image [expired user #9179] posted 9 years ago Permalink
Could you give me the command for this?
I´ve tried to import the data from the csv file but get another error.
In php I remember the Values has to be in backticks
1 attachment(s):
  • CSV
ansgar's profile image ansgar posted 9 years ago Permalink
The faulty query has 3 issues:
* the table name is missing "INSERT INTO ???"
=> I guess you have to add some "-table=XYZ" parameter.
* the column names are all missing " (??)"
=> Probably you need to pass the column names in the command.
* the values are all in one string "nummer;daten"
=> Probably you need to specifiy the field terminator (semicolon) in the command

These are all just guesses. Please look into the help listing, which you get with
mysqldbimport.exe --help

Please login to leave a reply, or register at first.