Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
generic sql database copy
I am about to write a generic database copy function. To get the order right, in which the tables must be copied, I need to know about references between tables, so that I copy the referenced table before the referencing table.
How could I find out, if a table has references?
Thanks for your time,
Most of the databases system have a dump method/helper application that should do the job.
Is it something like that that you are looking for ?
Unfortunately not. My question comes from a different direction: I write a database app with a very specific purpose. I assume, that the schema will have to change from time to time. But my assumption is, that as long as I keep the changes "compatible" - like only adding fields or changing fields from "not null" to "null allowed" it should be OK to create a database with the new schema and copy all existing data - at least for the columns, which exist in the source database.
So this copy should be a way to keep my databse always compatible with the application.
Sorry if this sounds complicated. I hope this is clear?
Thx and best regards
In that case, you might want to consider using migrations a bit like Django does so you do not have to take such limitations into account.
Not sure, what django refers to, to be honest. But I do not want the user to do anything - the conversion should just happen on the startup of my qt app.
That's why I search for a solution in Qt. ...
Sorry, the Python Django project. I referred to it as inspiration not as replacement.
OK - I got it. I will have a look.
But I have to admit, that this is the only piece that is missing - everything else I have done before and know how to do - so knowing about the references would really be helpful.
On the other hand: I might just use pragmas and switch references off - with this I should be able to copy the tables in any order ...
Anyhow - as always: thanks a lot for your support!