Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Class to read and save different objects in SQL database!!!
VincentWesley last edited by VincentWesley
I am trying to create a class that is capable of saving and reading objects of different type in a SQL database. The goal is to avoid redundancy of methods in each object class ( I could, for simplicity write my sql database methods in each object class that I want to save and read and it would work). The strategy I tried is to inherit my object classes with a class containing static methods. Additionnaly different object type have to be saved in different database.
As the database class contains static methods, I am obliged to use static member variables in order to save the database name and path. This is the point that is bothering me. Static variables can be initialized just once. Hence, the database name and path cannot be different for different objects.
https://trackeasy.fun/usps/ https://showbox.tools/ https://speedtest.vet/
My question is the following: what strategy should I use, if I want to have a single class that is capable of saving and reading different object types in different databases according to the object type.
Below I provide a minimal example of what I did and that is not the good strategy:
Pl45m4 last edited by
This might be helpful
class containing static methods
Why static methods?
What you're describing sounds like ORM. Take a look at existing libs like https://www.qxorm.com/qxorm_en/home.html