MySQL Errors when Reading

Back to topics list To post a new topic, please log in or register
avatar
2
kirkhilles 2015.10.28 14:07
 
Hi, Newbie here. I'm an experienced MySQL developer and am trying to get a reliable and consistent ability to read from a localhost MySQL 5.6 database. My code works, but there seems to be issues with it. First off, if I have more than 2-3 columns of data (1 row returned), it returns errors. Also, over time of querying once a minute for 22 Forex symbols (even returning 0 rows everytime), it eventually returns errors like the following: "Access violation read in 'libmysql.dll'", "mysql_init failed. There was insufficient memory to allocate a new object" and "Access violation read in msvcrt.dll". I'm hoping that there is some sort of memory free up command or something I can add or adjust to make my code work reliably. I'm currently setup using the MySQL DLL file and using the "mql4-mysql.mqh" include written by Sergey Lukin and its running on a Windows 10 32-Bit machine with MySQL 5.6 and using the DLL from it. Here is a simple function I wrote to try and isolate the code to its own function. This just returns the one column of data from one row: 
string getDB(string sSQL)
{
   string row3[][999];
   string sReturn;
  
   int dbConnectId3 = 0;
   bool bConnect = init_MySQL(dbConnectId3, DB_URL, DB_USERNAME, DB_PASSWORD, DB_DBNAME, 3306, 0, 0); 
   int row_result4 = MySQL_FetchArray(dbConnectId3, sSQL, row3);
  
   sReturn = row3[0][0];
  
   deinit_MySQL(dbConnectId3);
  
   return sReturn;
}

Any ideas? Thanks so much!
avatar
70
Keelan 2015.11.01 16:21 #
 
I don't know a great deal about MySQL other than for a few web sites I've made but have you checked your sql config? i can only think of 3 things, the DLL is misconfigured/set up, the sql server config has request data restrictions (one person can only pull so much data at a time) orrrr You need run your meta trader 4 client as admin and make sure the user for sql has relative permissions. Just out of curiosity have you tried initializing the row3 index? empty initializations don't have any heap set aside at compile time which would give you some access errors.
avatar
1109
Ovo 2015.11.01 16:59 #
 
Not sure if passing a string array to a DLL function argument is allowed in MQL4.
avatar
2
kirkhilles 2015.11.11 22:33 #
 

Thanks for the input. I have since given up on the concept of reading from MySQL and instead are just reading from Textfiles. Its certainly not a limitation of MySQL or capability issue as the system can handle many reads per second. In fact, the system is currently executing a REPLACE statement (not especially efficient either) for EVERY tick for 22 Forex symbols, so you can imagine how many queries are being executed at a time during busy periods. It does that flawlessly (as far as I can tell at least).

Oh well. Reading from a Textfile isn't ideal, but it works. If anyone finds a reliable means to read from MySQL, please add a note as I'd still be interested.

Back to topics list  

To add comments, please log in or register