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

To add comments, please log in or register
Eugeniy Lugovoy
2013
Eugeniy Lugovoy  

Hi all.

I've rebuilt DLLs and MQL libraries (of MQLMySQL) to support unicode, now reviewing all sources and will share on GitHub very soon.

Also I'm testing now MQLAdoDB project to work with different databases (MS SQL, Oracle, PostgreSQL, MS Access, etc) from MQL using AdoDB & OLEDB.

This project also would be available soon on GitHub, and of course it would be free.

Best regards,

Eugene

odlambda
22
odlambda  

Thank you very much as always for your time and help the community.


I will be attentive to the updates and looking forward to seeing the github to learn more. :)


Happy New Year to all!

Eugeniy Lugovoy
2013
Eugeniy Lugovoy  
The MQLMySQL library version 3.0 is released and published on GitHub: https://github.com/elugovoy/MQLMySQL-Project

Any further fixes & updates would be made in GitHub repository.


Codepage UTF-8 is supported now.


Project keeps 3 directories for:
- MQL4 x86 - function set
- MQL5 x64 (old school) - function set
- MQL5 x64 (classes) - classes for MQL5

<Deleted>


Happy New Year & good luck in development!

Eugene

elugovoy/MQLMySQL-Project
elugovoy/MQLMySQL-Project
  • elugovoy
  • github.com
The problem of interaction of MQL with databases is not new, however it's still relevant. Use of databases can greatly enhance the possibilities of MetaTrader: storage and analysis of the price history, copying trades from one trading platform to another, providing quotes/trades in real time, heavy analytical computations on the server side...
Cid Ougaske
3801
Cid Ougaske  
Eugeniy Lugovoy:
The MQLMySQL library version 3.0 is released and published on GitHub: https://github.com/elugovoy/MQLMySQL-Project

Any further fixes & updates would be made in GitHub repository.


Codepage UTF-8 is supported now.


Project keeps 3 directories for:
- MQL4 x86 - function set
- MQL5 x64 (old school) - function set
- MQL5 x64 (classes) - classes for MQL5

<Deleted>


Happy New Year & good luck in development!

Eugene

Hi Eugeniy, thank you so much for your contribution. It´s very usefull and really works! 

phlixetrader
6
phlixetrader  

Eugeniy Lugovoy:

The MQLMySQL library version 3.0 is released and published on GitHub: https://github.com/elugovoy/MQLMySQL-Project

Any further fixes & updates would be made in GitHub repository.


Codepage UTF-8 is supported now.


Project keeps 3 directories for:
- MQL4 x86 - function set
- MQL5 x64 (old school) - function set
- MQL5 x64 (classes) - classes for MQL5

<Deleted>


Happy New Year & good luck in development!

Eugene

Hi, wow thanks for all of this, there's a problem with my notifications so I've only just seen that you did this several months later.

Thanks very much, great work.

Peter

arsenico42
16
arsenico42  

Hi @Eugeniy Lugovoy and thanks for your hard work!

In the current version of your implementation, is there a way to retrieve the "LAST_INSERT_ID" after an INSERT operation (in a table with an AUTO_INCREMENT column)?

Thanks in advance and have a nice day :)
Eugeniy Lugovoy
2013
Eugeniy Lugovoy  
arsenico42:

Hi @Eugeniy Lugovoy and thanks for your hard work!

In the current version of your implementation, is there a way to retrieve the "LAST_INSERT_ID" after an INSERT operation (in a table with an AUTO_INCREMENT column)?

Thanks in advance and have a nice day :)


Hi arsenico42, you can try to make insert in one query and then select LAST_INSERT_ID in another one, but I cannot recommend this way, but I cannot recommend this way because LAST_INSERT_ID is function which returning global database variable, and another one insert (from another user, running concurrently) between your original insert and selection of LAST_INSERT_ID can affect LAST_INSERT_ID value.

This is not depended on library, it's how mysql/mariadb works.

But, I can advice you to create a function on database side to insert required values, select LAST_INSERT_ID and return this ID as function value. it might looks like:

CREATE FUNCTION `import_funds_add`(
        `p_file_name` varchar(64),
        `p_full_path` varchar(2000),
        `p_status` VARCHAR(10),
        `p_error` VARCHAR(2000)
)
RETURNS bigint(20)
LANGUAGE SQL
NOT DETERMINISTIC
MODIFIES SQL DATA
BEGIN
     declare id bigint;
     INSERT INTO import_funds(`file_name`, `full_path`, `status`, `error`, `creation_date`) 
     VALUES (p_file_name, p_full_path, p_status, p_error, now());
     SELECT LAST_INSERT_ID() INTO id;
     RETURN(id);
END;;

And in MQL you have to open cursor for query:

qry="SELECT import_funds_add('bonuses.csv','c:\\broker imports\\XXX-FX','NEW','No errors') as last_id";

then get value as from usual cursor and close cursor.

So, instead of using those commands separately in MQL you can just combine them on DB side into function.

it's just an example from live system.

Eugeniy Lugovoy
2013
Eugeniy Lugovoy  
Carmine Marrone:

Hello elugovoy

 Awesome article and great libraries.

 I'm trying to use your examples under MT5 but I'm getting this error: 

2014.12.15 15:44:16.387 MySQL-001 'C:\Users\....\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\libraries\MQLMySQL.dll' is not 64-bit version

Are you  running MT5 under 32-bit env?

 Could you pleas help me with it? 

 Thanks very much!

 Carmine Marrone. 

Hello Carmine, you can download x64 version from sources on github.

https://github.com/elugovoy/MQLMySQL-Project/tree/master/MQLMySQL/x64/Release

MARCOS DALCIN ALVES DINIZ
229
MARCOS DALCIN ALVES DINIZ  

Hey @Eugeniy Lugovoy, first of all thanks for all the contribution to the community


I'm stucked here:

"Cannot load 'C:\Users\Admin\AppData\Roaming\MetaQuotes\Tester\D0E8209F77C8CF37AD8BF550E51FF075\Agent-127.0.0.1-3000\MQL5\libraries\MQLMySQL.dll'" [126]

"Cannot call 'ReadIni', '..\libraries\MQLMySQL.dll' is not loaded"
Eugeniy Lugovoy
2013
Eugeniy Lugovoy  
MARCOS DALCIN ALVES DINIZ:

Hey @Eugeniy Lugovoy, first of all thanks for all the contribution to the community


I'm stucked here:

"Cannot load 'C:\Users\Admin\AppData\Roaming\MetaQuotes\Tester\D0E8209F77C8CF37AD8BF550E51FF075\Agent-127.0.0.1-3000\MQL5\libraries\MQLMySQL.dll'" [126]

"Cannot call 'ReadIni', '..\libraries\MQLMySQL.dll' is not loaded"

Make sure you have MQLMySQL.dll & MQLMySQL.def files located in your folder "C:\Users\Admin\AppData\Roaming\MetaQuotes\Tester\D0E8209F77C8CF37AD8BF550E51FF075\Agent-127.0.0.1-3000\MQL5\libraries\"

As you can see if you are running MQL programs in Tester mode, the path to libs would be different (because of UAC)

To add comments, please log in or register