Discussion of article "SQL and MQL5: Working with SQLite Database"

 

New article SQL and MQL5: Working with SQLite Database has been published:

This article is intended for developers who would be interested in using SQL in their projects. It explains the functionality and advantages of SQLite. The article does not require special knowledge of SQLite functions, yet minimum understanding of SQL would be beneficial.


Many developers consider using databases in their projects for data storage purposes and yet they remain hesitant about this, knowing how much extra time the SQL server installation may require. And whereas it may not be so difficult for programmers (if a database management system (DBMS) has already been installed for other purposes), it will certainly be an issue for a common user who might eventually be discouraged to install the software altogether.

So many developers choose not to deal with DBMS realizing that solutions they are currently working on will be used by very few people. As a result, they turn to working with files (often having to deal with more than one file, given the variety of data used): CSV, less often XML or JSON, or binary data files with strict structure size, etc.

However, it turns out there is a great alternative to SQL server! And you do not even need to install additional software as everything is done locally in your project, while still allowing you to use the full power of SQL. We are talking about SQLite.

The purpose of this article is to quickly get you started with SQLite. I will therefore not go into subtleties and all imaginable parameter sets and function flags but instead will create a light connection wrapper to execute SQL commands and will demonstrate its use.

To proceed with the article, you need to:

  • Be in a good mood ;)
  • Extract the archive files attached to the article to the MetaTrader 5 client terminal folder
  • Install any convenient SQLite Viewer (e.g. SQLiteStudio)
  • Add the official documentation on SQLite http://www.sqlite.org to Favorites

Author: o_O

 
Wonderful idea and article, I didn't think to that. It would be great however to have a native support in mql5, so that could be used in Market's product.
 

First of all  warm thanks for your work!

I ported it to mql4 with success! (some #property strict, solve the compilation errors.)

And as I use  32bit platform I had to comment out and delete some 64bit related import functions. The terrminal uses early binding, so 64 bit-dll also try to load during the program load. (altough it is not used, only the 32bit.dll.). It made error. 

But anyway, I like your implementation! ( I wish I colud write so good prog as yours.)

 
I am using a 64 bit version of MetaTrader 5 and am not able to get the code working. I tried removing the references to 32 bit code but still get an error "Sqlite3_32.dll" cannot load. Can you tell is the code referencing this dll anywhere ? I need to get it working for 64 bit.
 
MetaQuotes Software Corp.:

New article SQL and MQL5: Working with SQLite Database has been published:

Author: o_O


Do you have a 32 bits version ?

The issue is i have a lot of 32 bit customers...

 

I think I found a memory leak:

In SQLite3Base.mqh line 250

::sqlite3_finalize(stmt); // clean

 Should be:

::sqlite3_finalize(pstmt); // clean
 
A new article implementing a native SQL solution can be found here: https://www.mql5.com/en/articles/7463
SQLite: Native handling of SQL databases in MQL5
SQLite: Native handling of SQL databases in MQL5
  • www.mql5.com
MQL5 is a perfect solution for algorithmic trading since it is as close to C++ as possible in terms of both syntax and computation speed. The MetaTrader 5 platform offers its users the modern specialized language for developing trading robots and custom indicators allowing them to go beyond simple trading tasks and create analytical systems of...
 
Quintos:

I think I found a memory leak:

In SQLite3Base.mqh line 250

 Should be:

Good catch!
(Any tools avilable to check these things?)
Reason: