distal-attribute
distal-attribute
distal-attribute
distal-attribute

# Run script on connection

rollsroycejohn posted 6 years ago in Running SQL scripts
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 posted 6 years ago
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 ...

rollsroycejohn posted 6 years ago
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 posted 6 years ago
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.
rollsroycejohn posted 6 years ago
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 posted 6 years ago
I'm curious - what problems?
rollsroycejohn posted 6 years ago
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 posted 6 years ago
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 posted 6 years ago
Startup script is implemented, just update to the latest build please.
rollsroycejohn posted 6 years ago
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.