Discussion of article "How to Access the MySQL Database from MQL5 (MQL4)" - page 18

 

Hello, I read this document interestingly.

Could I ask you a question?

I wanna know how to confirm the connection with MySQL.

Please teach me how to confirm the connection.


About original japanese: And on Monday, when the market starts, an error is found in the project. Therefore, we strongly recommend that you confirm the connection and/or reconnect to the database at intervals smaller than the timeout specified in the server configuration.

That means: after then, you will find out an error in your project on Monday. So, I recommend you to confirm that the connection is alive or dead at a time interval shorter than the timeout server settings.


Thank you.

 

Hello,...

I wrote the code for the time being like below. 1.

Create a table that has a time record when confirm the connection. 2.

Create a table that has a time record when confirm the connection. 2.

If the UpSert will be failed, try resync with MySQL.

Please tell me if some methods exist to confirm the connection.

Please tell me if some methods exist to confirm the connection.

//+------------------------------------------------------------------+
//| Check and reconnect MySQL connection &nbsp ; & nbsp; |
//+------------------------------------------------------------------+
bool DBAccess::resync(void)
{
    string  qry = "";

    string  update_time = (string)TimeCurrent();

    qry += "INSERT INTO `" + sync_table + "` (id, update_time) ";
    qry += "VALUES (\'sync\', \'" + update_time + "\') ";
    qry += "ON DUPLICATE KEY UPDATE update_time = \'" + update_time + "\';";
    
    if (MySqlExecute(DBID, qry))    { return true; }
    
    echo("[Try] Database has been disconnected. EA will try resynchronization.");

    bool    sync        = syncDB();
    
    if(!sync)   { return false; }

    return true;
}
for the time beingの意味・使い方 - 英和辞典 Weblio辞書
  • ejje.weblio.jp
for the time beingの意味や使い方 当分の間, さしあたり, 目下. - 約1037万語ある英和辞典・和英辞典。発音・イディオムも分かる英語辞書。
 
Is there anyone here who can write a wrapper from MQL5 to MS SQL, and also interested in a wrapper for VOLTDB.
 

I would like to ask, I did not disconnect the database operation, but the database is just beginning to connect data normal data over time, can not directly read the database information, but there is no error message

I use MT4

Files:
20180412.log  2067 kb
 
cikahun:

Hi Alain,

Thanks a lot! I could figure it out what was wrong.

In my case the broker gives me the currency symbol with a £ sign. I've deleted it and it works.

Thanks again.

I am also encountering this error as my broker also suffixes symbols with (£). Does anyone know why this causes an issue and what the solution is? The SQL string works fine when entered into MYSQL Workbench but I get the "Query was empty" message when running the query through this library.
 
Eugeniy Lugovoy:

Thanks for your time reading this artice. I've also checked your (https://www.mql5.com/en/code/11114), I've found such solution a long time ago (before MT4 build 600) and I liked the idea to make MQL and MySQL friendly. But just one thing I don't want to use is arrays to retreive the data from database. That's why I've built this solution for using with MT4 and MT5.

Also, I forgot to add x64-based project to the article, so you can download it right here, in discussion. Nothing was changed in sources, just DLL has been recompiled for x64.

Good luck,

Eugene 

hi Eugeniy Lugovoy , thanks for your article, I used  x32-based project in my (64bit windows with mql5) and I had this error :

2018.06.04 17:58:52.879    MySQL-001 (XAUUSD,H1)    Cannot load '..\libraries\MQLMySQL.dll' [126]

and now Im trying to use your x64-based project that you uploaded that in this forum but i still have above error .

I tried to run one of scripts in 2 ways ,

first I put dll files in this address : ...\MQL5\Libraries

second I put them in this address :  C:\Windows\SysWOW64

but neither of them worked . 

 

Hi  Eugeniy Lugovoy 


I'm getting the following error not sure what is up!


The errors occurs on the MQLMySQL.mqh file

'StrToInteger' - function not defined MQLMySQL.mqh 224 10


'StrToDouble' - function not defined MQLMySQL.mqh 229 10

on the following lines of code:



int MySqlGetFieldAsInt(int pCursorID, int pField)

{

 return (StrToInteger(MySqlGetRowField(pCursorID, pField)));

}


double MySqlGetFieldAsDouble(int pCursorID, int pField)

{

 return (StrToDouble(MySqlGetRowField(pCursorID, pField)));

}


Kind Regards,



 
MetaQuotes Software Corp.:

New article How to Access the MySQL Database from MQL5 (MQL4) has been published:

Author: Eugeniy Lugovoy

Hi Eugeniy Lugovoy,

Firstly, thank you for taking the time to make this project.

I've been looking for weeks on how to import/update all the open/closed trades from a trading account into a MySQL table, if possible realtime.  is there a way to do this using your library?

Many thanks in advance.

Dragos

 

win2008 Or win10 X64

run Log


2018.09.15 20:10:26.742 MySQL-001 (EURUSD,H1) Cannot load 'C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\ 67381DD86A2959850232C0BA725E5966\MQL5\libraries\MQLMySQL.dll' [193]

2018.09.15 20:10:26.742 MySQL-001 (EURUSD,H1) Cannot call 'ReadIni', '... \libraries\MQLMySQL.dll' is not loaded

2018.09.15 20:10:26.742 MySQL-001 (EURUSD,H1) unresolved import function call



SomeBody Help

 
Eugeniy Lugovoy:
For x64 platforms, use the following libraries (with discussion)

win2018R2 Or win10 X86


2018.09.15 20:10:26.742 MySQL-001 (EURUSD,H1) Cannot load 'C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\ 67381DD86A2959850232C0BA725E5966\MQL5\libraries\MQLMySQL.dll' [193]
2018.09.15 20:10:26.742 MySQL-001 (EURUSD,H1) Cannot call 'ReadIni', '... \libraries\MQLMySQL.dll' is not loaded
2018.09.15 20:10:26.742 MySQL-001 (EURUSD,H1) unresolved import function call


????