Copy tables between sqlite databases, qt, causes error Copy tables between sqlite databases, qt, causes error sqlite sqlite

Copy tables between sqlite databases, qt, causes error


We can read from the Qt documentation about QSqlDatabase :

Warning: If you add a connection with the same name as an existing connection, the new connection replaces the old one. If you call this function more than once without specifying connectionName, the default connection will be the one replaced.

So when you add a database multiple times within a specific name or without specifying any (default connection), the connection is replaced and that warning appears.

you should call QSqlDatabase::addDatabase() once for each of the databases with different connection names :

database = QSqlDatabase::addDatabase("QSQLITE", "database_Connection");mHistoryDB = QSqlDatabase::addDatabase("QSQLITE", "mHistoryDB_Connection");