A
A
Anatoly Medvedev2015-08-07 12:52:17
MySQL
Anatoly Medvedev, 2015-08-07 12:52:17

How to work with MySQL correctly in Qt?

Hello. I started learning Qt not too long ago, I used it to create guis in my little helovods.
At the moment I work in a call center as a programmer where a simply terrifying necrophiliac technology stack is applied straight from the beginning of the millennium - Windows Server 2000 + MS Acess 2000 + a self-written program (apparently it was Delphi) through which the operator (s) works with this database. Despite the very small size of the database (slightly more than 500 thousand rows in the "main" table), we have extremely low performance (we wait up to 20 seconds for the result of the query). Plus, all this is spinning in a virtual machine, since the system cannot work on modern equipment due to the lack of drivers. As you can understand, the system is firmly nailed not just to one OS, but to its specific version (on other systems, the "program" refuses to work correctly). In addition to everything, there is no source code for this program.
The boss has been toying with the idea of ​​"rewriting the program" for a long time. But there is no time for this, then there is no money. Therefore, as a self-development and gaining useful experience, I decided to take on this work.
I took MySQL as a DBMS.
Qt/C++ language stack.
I want to make the program cross-platform and preferably not nailed to the DBMS alone, it is supposed to be easily replaced with, for example, Postgre.

I apologize for such a long introduction, what is the point:

there is a table like this:
ID_Firm, ID_Name, ID_Type, ID_Mark, Rank, Description
2, 15, 4, 8, 100, description
8, 1, 5, 8, 100, description2
6, 5, 12, 3, 100, description3
Accordingly, there are reference tables for Firm, Name, Type, Mark of the form
ID, Name , + - a few more fields, depending on what it is
1, "Gosnarkokontrol
" database interaction, it's like SqlQuery, SqlTableModel, SqlRelationalTableModel.
There is a filter window, which consists of a ComboBox, where the elements are selected by which to select. I can’t figure out how to organize it so that, for example, if we chose the brand we need, then you are the model selection field, we could choose only this brand from the models, and stuff like that. At the same time, I don’t want to load this entire table to the client from the database every time, but to form a request and shift the entire load to the server.
What interaction model to choose for this? I started trying with SqlQuery but quickly got caught up in query noodles and the crutches of gluing multi-line queries together. Is it possible to exclude writing SQL queries in the code at all? I looked in the direction of ORM, but I have no experience working with them and it seemed too complicated, there are no adequate examples of work (helowwords on sites as examples do not count, everything is simple in them, including the initial task), despite the fact that there is no sensible documentation in Russian , which is not so critical, but I would like to.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antony, 2015-08-07
@RiseOfDeath

The boss has been toying with the idea of ​​"rewriting the program" for a long time. But there is no time for this, then there is no money.

Well, if not, then no. No need to stress then. Find something better for yourself.
By subject - depending on the task and data organization, choose a model. In general, it looks like the usual SqlTableModel will suit you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question