A
A
AlexSer2019-11-22 13:43:57
Qt
AlexSer, 2019-11-22 13:43:57

How to run both Mysql and SQlite at the same time in Qt?

How to run both Mysql and SQlite at the same time in Qt?
Saving records should go simultaneously in both Mysql and SQlite.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2019-11-26
@AlexSer

It is necessary to create an object with different names, they are set in the second parameter.
For example like this:

QSqlDatabase::addDatabase("QMYSQL", "ClassName1")
QSqlDatabase::addDatabase("QSQLITE", "ClassName2")
If you add two connections with the same name, the second one replaces the first one.
After the database is closed, you can use names to remove connections.
QSqlDatabase::removeDatabase("ClassName1");
QSqlDatabase::removeDatabase("ClassName2");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question