How can I count the number of rows of a table in a database X ?
How can I count the number of rows of a table in a database X ? I used the following code but it does not work:
Although there is no DatabaseRowsCount function, you should be able to work with DatabaseRead():
//--- Data reading int request = DatabasePrepare(handler,"SELECT * FROM trades;"); //--- Number of table columns that were read int size_cols = DatabaseColumnsCount(request); //--- While data is available for reading (reading each line) while(DatabaseRead(request)) { //--- Scan across all columns of the current line of reading for(int j=0;j<size_cols;j++) { string name = ""; DatabaseColumnName(request,j,name); logs.Info(name,"TickORM"); } } //--- Reset query DatabaseFinalize(request);
"Here, the query SELECT * FROM trades; fetches all records from the "trades" table. Each call to DatabaseRead(request) moves the cursor to the next row, and the inner loop goes through all the columns, printing only the names" (emphasis added).
Simplifying Databases in MQL5 (Part 1): Introduction to Databases and SQL
joaopedrodev, 2025.08.27 12:42
We explore how to manipulate databases in MQL5 using the language's native functions. We cover everything from table creation, insertion, updating, and deletion to data import and export, all with sample code. The content serves as a solid foundation for understanding the internal mechanics of data access, paving the way for the discussion of ORM, where we'll build one in MQL5.Which database kindly elaborate
An SQLite database, presumably:
- www.mql5.com
How can I count the number of rows of a table in a database X ? I used the following code but it does not work: