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

Launching from command line

User, date Message
Written by chorlya
7 years ago
Category: General
23 posts since Fri, 11 May 07
Is it possible to start HeidiSQL from command line and pass it connection parameters from there?

I don't think there is such an option at the moment, and as far as I know no other MySQL GUI out there has that option (both open-source and commercial).
This feature is really a "must have" when servers you connect to, or their params, change often. It gets really tiresome to update connection params in multiple programs all the time so I've created a small app that enables me to keep all connection information in one XML file and use that app to launch any other program passing it appropriate parameters. This works like a charm for PuTTy and WinSCP, but I can't find a MySQL GUI that will accept connection parameters on command line.

If this feature is not available in HeidiSQL right now, does it sound like feature worth implementing in foreseeable future?

Thanks for HeidiSQL! I've been using MySQL-Front since early 2.X days and always found any other tool to be lacking some features or just too weird to use. I guess it just gets under your skin. :D
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Oh that sounds easy to implement. Just look for given parameters on startup (and connect automatically instead of waiting for the user to click "Connect"?)

Just let us gather needed parameters here:
- host
- user
- pass
- port
- maybe a database name to use?

So it could look like

heidisql.exe -hLocalhost -uUser -pPassword -db



We could even simulate the mysql-cli's behaviour which is quite good:
either
- use a given password from "-p" and connect immediately
- if an empty password given, ask for it and don't connect immediately
- if no -p parameter given, assume we have to connect with an empty password

How does that sound?
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07

anse wrote: Oh that sounds easy to implement. Just look for given parameters on startup (and connect automatically instead of waiting for the user to click "Connect"?)


Exactly that.

anse wrote: Just let us gather needed parameters here:
- host
- user
- pass
- port
- maybe a database name to use?


I would definitely find db name useful, plus I think there should be an optional description parameter so if there are multiple instances of Heidi open, you can easily find the right one in task bar. This description should behave exactly the same as "Description:" in connection dialog.

anse wrote: So it could look like

heidisql.exe -hLocalhost -uUser -pPassword -db



We could even simulate the mysql-cli's behaviour which is quite good:
either
- use a given password from "-p" and connect immediately
- if an empty password given, ask for it and don't connect immediately
- if no -p parameter given, assume we have to connect with an empty password

How does that sound?


Puts a big smile on my face. :D
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
anse,

is this feature by any chance already implemented in svn trunk?
If so, is there a nightly build or something like that since I don't have Delphi to build it my self.

Thanks
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Sorry, not yet implemented and no nightly builds yet.

But: I started to implement that a few weeks ago and then stopped it for the benefit of other implementations. Maybe the code I wrote is useful and helps me implementing it soon.

And: I'm on the way to create a workflow for compiling nightly builds. Will need some more days or maybe 2 weeks.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
Thanks for the update. I hope you'll get to it soon. happy

Once you implement it, perhaps you can update this post with a link to build that includes this feature so we (community) can test it right away.

Thanks
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
I'm currently working on a batch file for the process of creating nightly builds. The compiler dcc32.exe needs about one million options and I'm having problems with one of them. I can't get it to "Build all units" (-B), although I switched that on:

...
-B
-I"components\zeosdbo\src\core"
...



Won't create the .DCU files here as expected. :cry:

Anyone with hints for me?
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
Visual Studio 2005 will generate BuildLog.htm for C++ projects. That file includes the commands that IDE used to build your project. Does Delphi has such an options? If so, you can probably deduce from that what IDE is doing differently.

Perhaps the order of options is important? Did you try to specify include directives first?
Maybe you should just post you whole batch file here in hopes that someone will catch some sneaky little error in it.

Sorry, can't help you more with this issue.
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
I just read that Delphi 2007 has some support for msbuild which means you can build a project by just giving the projectgroup-file. msbuild then should generate a commandline for dcc32.exe. Not sure how to get it working on the commandline, but I'll look for it.

Is msbuild something I have to download seperately?
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
If you have .NET 2 installed, I believe you should already have it installed in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder or something like that. If not, perhaps you only have .NET 2 runtime in which case you'll need to install .NET 2 SDK.
Written by waldemar
7 years ago
4 posts since Wed, 22 Nov 06

anse wrote: Just let us gather needed parameters here:
- host
- user
- pass
- port
- maybe a database name to use?



- host
- user
- pass
- port
- maybe a database name to use?
- batchscript_to_execute.sql
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06

chorlya wrote: ... you should already have it installed in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder or something like that.



Yep, found it in exactly that directory.

Seems easy:

\windows\Microsoft.NET\Framework\v2.0.50727\msbuild superpackages\delphi11\heidisql.groupproj

Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
See here for latest builds:
http://download.heidisql.com/
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
Wow, great news anse.

Now I just need to wait for command line thingy to be implementedhappy
Or shall I say I'll keep an eye on a FishEye 8)

Thanks!
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Fisheye has RSS feeds btw. For example checkout this one:
http://fisheye3.cenqua.com/changelog/~rss/heidisql/trunk/rss.xml
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
Yeah, I subscribed to that when I wrote my previous post. Thanks for pointing it out anyway, though.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
I just upgraded from 3.0 to 3.2 and AFAICT, there is no support for command line parameters yet? :(
Just wanted to confirm that and ask if this is still planned for implementation some time soon?

btw. Nice work on 3.2, keep it coming.

Thanks
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
A command line parser is a complex thing, not implemented in some hours. In addition my old code is unusable for that as I recently found out. Had some logical errors, so I need some new ideas for implementation.

Maybe you can help out with that feature?
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07

anse wrote: Maybe you can help out with that feature?


I sure can try. I'm not a Delphi programmer, but if you think I can help you in some other way please let me know.

This is a long shot, but if there is some free or trial version of Delphi that I can use to build Delphi programs myself maybe I can try implementing command line parser by itself and if successful hand it over to you to integrate it into Heidi. Do you know of any such download?

I still think that copying mysql.exe behaviour for relevant command line parameters and adding --session="session name" option would be a good solution.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
To answer my own question. There is a Delphi Turbo Explorer availabe for free here. And there is also a 30 day trial for Delphi 2007 and 2006 in case this Turbo doesn't work out for some reason.

I will download the Turbo version and see if I can find my way around it.
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Any help is very appreciated!

However, I think the Turbo versions don't support installing 3rd party components of which we have some in HeidiSQL. So, I'd recomment installing a 30 day trial of Delphi 2007.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
I installed Delphi 2007 Trial but it doesn't seem to work as advertised. They claim on the download page that it is a "fully functional" 30 day trial version, but command line tools are not supported in trial version. That is the message you get when you try to use them.
I then tried to install the components manually, but that didn't work either. Even their demos that use third party components, like Indy, don't work because of components not installing. So I'm under the impression that free trial version also doesn't support installation of third party components, but I can't find any info on that. All in all, such a bad experience with Borland/CodeGear so far. Not to mention that documentation alone took well over an hour to install.

I am able to work on the command line parser with this trial version, so I'll see if I can get anywhere with it. I remember that I saw some free e-book on Pascal some time ago, but I can't google it now. Do you know of any free Pascal/Delphi language reference available online? Only RadStudio and VCL reference come with RadStudio 2007, but I could also use some language reference.

Off-topic: I'm not receiving notification emails for new post to topics that I am subscribed to. Are you aware of any problems with forum not mailing out notification emails?
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Oh that's too bad with the trial. However, you don't need to install the whole HeidiSQL packages to work on that parser. You could create a small command line application and make it fill some variables like sessionname, host, user, password etc. In the end some other can integrate that snippet into HeidiSQL's childwin or whatever.

And thanks a lot for the info about not receiving mails! It seems the mailserver doesn't do its job since we moved the website to our own virtual private server system.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07
To answer my own question again, I found some decent Delphi language/library reference here.

I now have some code that can parse long parameters, see below for examples. Since ParamStr() returns AnsiString values, I used AnsiStr functions throughout. Is that going to be a problem in some situations?

This is parsed correctly:

heidisql.exe --user=root --host=192.168.1.1 --password --session="My session name"

Values are returned as expected, except for password in which case we know that --password is present but its value is set to empty string.

But none of these will be parsed correctly at the moment:

heidisql.exe --user root --host 192.168.1.1 --password --session "My session name"
heidisql.exe -uroot -h192.168.1.1 -p -s"My session name"
heidisql.exe -u root -h 192.168.1.1 -p -s "My session name"

First one is, I think, not really accepted by mysql.exe either?
Second one could probably be made to work with not too much effort, if need be.
But last one would require some substantial changes, though still doable if really required.
That is what I wanted to discuss, what formats exactly are we looking to support? Long options as they work now in my first example above are good enough for me, but I'd like to hear what others think.

If I manage to compile Heidi, what would be the best place for this code/logic? Where in childwin, OnCreate? Or some other place?
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
This is awesome and really helpful!

Regarding your question where to put that code: I think that's a quite complex thing. Normally Tconnform initializes the mysql connection and creates a TMDIChild. In this case we don't need Tconnform, so TMainform.FormShow should do the connect instead of passing all responsibility to TMainform.ShowConnections() + Tconnform.ButtonConnectClick(). I think we should move some code from Tconnform.ButtonConnectClick() to main.pas, call that from both places (command line passed parameters AND Tconnform.ButtonConnectClick() ).

However, once it's ready I think you should send the code snippet to heidisql-devel ...at... lists.sourceforge.net so I can discuss that with the other developers.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07

anse wrote: In this case we don't need Tconnform, so TMainform.FormShow should do the connect instead of passing all responsibility to TMainform.ShowConnections() + Tconnform.ButtonConnectClick(). I think we should move some code from Tconnform.ButtonConnectClick() to main.pas, call that from both places (command line passed parameters AND Tconnform.ButtonConnectClick() ).

Yes, connection logic should be moved to main.pas somewhere and act upon passed parameters, regardless of where they're coming from.

In case of --password or -p user will need to be prompted for a password. This will probably be better done from where ever the startup params are parsed and before the connect function is called.
Preferably that prompt will be a very simple modal dialog with a label like "Enter password for user@host", a password box below and OK Cancel buttons on the bottom.

I'll be mailing the code to devel list right away.

btw. I just received 4 notification emails, so it seems your mail server is working now.
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06

chorlya wrote: btw. I just received 4 notification emails, so it seems your mail server is working now.



Hehe. Exactlysmilethe mailserver was not configured properly yet since we moved to another machine.
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Thanks a lot for the code snippet! That will be very helpful and even looks like clean and well designed code. happy Only the CRLF constant already lives in const.inc but that's a minor thing.

However, I'll start to get it in asap. I'm working on replacing the two datagrids by TNT components, but that's nearly ready, so just gimme a week or so.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07

anse wrote: Only the CRLF constant already lives in const.inc but that's a minor thing.


I've only put that in so I can print the results of parsing, plus I did that as a standalone project so I didn't have access to heidisql files. But that won't be needed in heidi anyway, since heidi will not just print those to some message boxhappy

anse wrote: However, I'll start to get it in asap. I'm working on replacing the two datagrids by TNT components, but that's nearly ready, so just gimme a week or so.


Great! I'm looking forward to it.
If you remember, please update this post once that code is available in nightly build.
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Done in revision 1155.

Download nightly build here in 20 minutes.

A big, big thanks goes to Nemanja! happyhappy 8)
Written by ansgar
7 years ago
5023 posts since Fri, 07 Apr 06
Btw, the wrapper function MyParam was not really needed and I dropped it. You got this error "Missing operator or semicolon" because there was a variable paramStr which conflicts with a function of the same name. I just renamed the variable and it worked.
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07

anse wrote: Btw, the wrapper function MyParam was not really needed and I dropped it. You got this error "Missing operator or semicolon" because there was a variable paramStr which conflicts with a function of the same name. I just renamed the variable and it worked.


OK, great. I couldn't really figure out what the error was about, so I put it in a wrapper function and the worked, so...
Even though I should have noticed that, I wouldn't really call the error message "descriptive". :)
Written by chorlya
7 years ago
23 posts since Fri, 11 May 07

anse wrote: Done in revision 1155.

Download nightly build here in 20 minutes.


Ansgar,

thank you very much for this one. And Heidi in general, of course. :D
I just did a quick test, and it seems to work perfectly. Thanks so much!

I think you should "advertise" this feature of Heidi a bit more since, as far as I know, this is the only MySQL GUI tool that has this capability. On any platform, not just windows. Again, this is only AFAIK. Though I did do fair bit of research on the subject. By "advertise", I mean something like mention it in a feature list and README, etc.

btw. I never told you how awesome your nightly builds system is. I really like how you put it together like a generally useful AND usable service, instead of just a dump of latest code in executable form. Great work on that as well!
 

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