EAX_Mysql - MySQL library - Library for MetaTrader 5 - MT4/MT5 resources
I stumbled across MQL5 and was forced to put together the MySQL library. As with any library, I want examples to show how to use the library. What's really most important with any library is the examples of how to use it ;)
#includeEAX_Mysql *db = new EAX_Mysql(); Database Connection( "myhost.mydomain.com" , "my username" , "my password" , "my database" , "my table" ); integer iResults = db.read_rows( "Select password, COUNT(*) as number of clicks from user GROUP BY password" ); for ( integer i = 0 ; i < i results; i++) { string password = ( string ) database. get ( "password" ,i); Integer hits = ( integer ) database. get ( "hot" , i); }
#include//Global EAX_Mysql *db = new EAX_Mysql(); blank initialization () { DatabaseConnection( "myhost.mydomain.com" , "myusername" , "mypassword" , "meta-trader" , "tick" ; } Blank check () { MQTick tick; SymbolInformationTick ( _symbol ,tick); //Add a new data set to the table Ticks db.AddNew( "Ticks" ); // Fill it with values.. database.set( "symbol" , _symbol ); // If MySQL can convert, you can send numbers to numeric database fields database.set( "ask" , check.ask); Database.Settings( "Bid" , Check.Bid); database.set( "last" , tick.last); Database.Settings( "time" , String time (tick.time,TIME_DATE) + " " + String time (tick.time,TIME_SECONDS)); Database.Settings( "Volume" , tick.Volume); db.write(); } Blank solution initialization () { // Clean the memory and delete the database; }
Interact with data
EAX_Mysql *db = new EAX_Mysql(); Database Connection ( "myhost.mydomain.com" , "My Username" , "My Password" , "Meta Trader" , "My Table" ) // Select the table AgentsOnline (needs to identify the correct primary key) database. Select ( "Agent Online" ); // Read the data set with the primary key of 5. Read from the database ( "5" ); // Modify any column in the database. put ( "lastupdated" , ( string ) time local()); // write back to db.write();
Install:
Attachment download
📎 eax_mysql.mqh (29.79 KB)
Source: MQL5 #855
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •