Run script on connection

[expired user #4723]'s profile image [expired user #4723] posted 14 years ago in Running SQL scripts Permalink
I'm new to HeidSQL coming from MySQL-Front. Is there a method of automatically running an SQL script on connection with a database like there is with MySQL-Front?
ansgar's profile image ansgar posted 14 years ago Permalink
Run or load?

From Help > Readme:

*** Command line switches

Although HeidiSQL is a pure GUI application, it can be automated for connecting
and opening files via command line parameters. Parameter names are case sensitive
and are based on those used by the MySQL command line applications, e.g. mysqldump.

-d, -description Session name
-h, -host Host name
-u, -user User name
-p, -password Password
-P, -port Port (defaults to 3306 if not given)
-S, -socket Socket name (for connecting via named pipe)

Examples:

* Start over using stored settings from session "xyz":
c:\path\to\heidisql.exe -d=xyz
c:\path\to\heidisql.exe -description=xyz

* Connect with different username or port:
c:\path\to\heidisql.exe -d=xyz -u=OtherUser
c:\path\to\heidisql.exe -d=xyz -P=3307

* Connect to a non-stored session:
c:\path\to\heidisql.exe -h=localhost -u=root -p=Mypass -P=3307

* Open multiple .sql files in query tabs:
c:\path\to\heidisql.exe fileA.sql path\to\fileB.sql fileC.sql ...

[expired user #4723]'s profile image [expired user #4723] posted 14 years ago Permalink
I meant run a short updating script on connection to a specific database/table as follows:
TRUNCATE TABLE `availability`;
LOAD DATA LOCAL INFILE 'C:\\EXPORT.CSV' INTO TABLE `availability`
FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'
In MySQL-Front this can be put into a start-up property for a specific session.
ansgar's profile image ansgar posted 14 years ago Permalink
No, there is no "startup script" feature in HeidiSQL.

I would recommend using mysql.exe and a scheduler (crontab or Windows scheduler) to create such automated jobs. Or a MySQL event using MySQL 5.1 or later.
[expired user #4723]'s profile image [expired user #4723] posted 14 years ago Permalink
Ok, thanks for your info. I thought I'd found a solution to the problems which MySQL-Front is causing through it's demise.
ansgar's profile image ansgar posted 14 years ago Permalink
I'm curious - what problems?
[expired user #4723]'s profile image [expired user #4723] posted 14 years ago Permalink
As you may know the originator of MySQL-Front has left the product and it seems to be in a state of limbo at the moment. I had a copy on evaluation but after the eval period it went into lite mode and some features like import/export are not available unless you purchase a licence. However due to the situation no new licences are available. Additionally the program's auto update feature keeps telling me a new version is available each time I start up when it's actually up to date. Reading the news on their website there was some talk about giving the code to Heidi!!
ansgar's profile image ansgar posted 14 years ago Permalink
Oh, yes I read that talk about Heidi, but didn't take that too serious, as I had serial fights per mail with the original author some years ago (don't ask for details, these discussions were so incredible superfluous).

Maybe i can add some missing things to HeidiSQL to make it easier for you to migrate. At least the above mentioned startup script feature sounds nice somehow. Could live in the session manager dialog. Request it as a new feature?
ansgar's profile image ansgar posted 14 years ago Permalink
Startup script is implemented, just update to the latest build please.
[expired user #4723]'s profile image [expired user #4723] posted 14 years ago Permalink
Works like a dream! Now can update MySQL database from data within a local Foxpro database at very few keystrokes. Thanks.

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