Attach MySQL to MQ4

 

Hello, dear experts!

When writing an Expert Advisor, I really miss the ability to access the database!

Please tell me how to connect to the database.

Since I am already familiar with MySQL, it is better to use it.

 
 
Eugene1:

Hello, dear experts!
I really miss the ability to access the database when writing an Expert Advisor!
Please advise how to connect to the database.
Since I'm already familiar with MySQL, it's better to use it.


Unfortunately, you can only add data to the database using MQL.

But to read from it - only with the help of your DLL.

 

It is also possible to read using the standard DLL from MySQL.

There are a number of complications, but all are solvable.

 
HIDDEN:

It is also possible to read using the standard DLL from MySQL.

There are a number of complications, but all are solvable.


How is it solved?
saw your thread https://www.mql5.com/ru/forum/129879
 

Actually MKL4 works normally with muscle (receives and sends data) via libmySQL.dll. There is no problem with MKL4, but with MKL5 there is a big problem because of the Unicode. In the database information is normally sent, but returned hieroglyphs (if you browse the database in other programs, all displayed normally). At this stage I had to write a dll converter for MKL5.

//----------------------------------------------------------+
function a2u(var s:pansichar):PWideChar; stdcall;
//----------------------------------------------------------+
var
  w: WideString;
begin
  w := s;
  Result := PWideChar(w);
end;

The code is in Delphi. The muscle is working with MT5 in such a way. I want to get rid of this dll, I would appreciate it if somebody would tell me how to do it.

I have a class to work with SQLite from MT5, there is a proposal to write a similar class for the muscle.

Another funny thing about muscle is that libmySQL.dll has constant errors that cause the terminal to crash or stop the program. I strongly recommend to switch to MariaDB. It is fully compatible with muscle and works much more stable, for 2 weeks no error has popped up yet.

 
Graff:

In fact, MKL4 works normally with muscle (receives and sends data) via libmySQL.dll. There are no issues with MKL4

how do you get the data from the returned structure pointer?
 
sergeev:
how do you get the data from the returned structure pointer?


If you can help write ansi to unicode converter for MKL5, code of which is given in previous post. I will send you working code for MKL4, also it will help when writing class for MKL5.
 
Graff:

the ansi to unicode converter for MKL5, the code of which is given in the previous post.

in delphi not so much. i need to see the problem, as in MQL it can be solved in different ways. or via uchar array or CharToString etc.

 
sergeev:

I need to see the problem, because in MQL it can be solved in different ways. or via uchar array or CharToString etc.


Add me on Skype or ICQ (contacts in my profile on MKL5 website). I will send you all the source code for MKL4 and MKL5 at once, but I need help with string conversion.
 
Graff:

Add me on Skype or ICQ (contacts in my profile on the MKL5 website). I will send you all the source code for MKL4 and MKL5 at once, but I need help with converting lines.

Better in person.