[Lazarus] Getting MySQL process output

Michael Van Canneyt michael at freepascal.org
Sat Dec 5 15:34:34 CET 2015



On Sat, 5 Dec 2015, Aradeonas wrote:

> [Cross posted on forum so if you want answer there : http://forum.lazarus.freepascal.org/index.php/topic,30635.0.html ]
>
> Hi,
>
> I want to play with MySQL process and get what ever it write to console
> so I write this code:
>
>> Process := TProcess.Create(nil);  with Process do  begin
>> Executable := 'C:\Program Files (x86)\MySQL\MySQL Server
>> 5.5\bin\mysql.exe';    with Parameters do    begin      Options :=
>> [poUsePipes];      Add('-u');      Add('root');      Add('-p');
>> end;    Execute;    while Process.Running do
>> Memo1.Lines.LoadFromStream(Process.Output);    end;
>
> But the problem is that this will freeze because there is no output but
> console window write :
>> Enter password:
> How can I get this in my application and all others?

Simply said: You cannot.

>
> As I said I want to work with MySQL executable and read from and write
> in it, So I dont want to use its library or any other DB component.

Specify the password on the command-line.
Then maybe you can read the output, but I doubt things will work very well, 
since mysql uses line editing features.

Michael.


More information about the Lazarus mailing list