I
I
IvanFaQerstein2015-01-23 13:31:46
MySQL
IvanFaQerstein, 2015-01-23 13:31:46

Qt+MySQL. How to connect the database and transfer to other machines along with the program?

Hello. I have exhausted the possibilities of search engines that talk about connecting a MySQL database to Qt, so I'm asking here. I need a database to store information from which Qt will request data. Everything is simple and trivial. But since my experience with the DBMS is extremely small, I do not represent the organization of the entire process. This leads to questions: "Is it possible to supply my MySQL database in *.sql?" program?", "What and where should I shove to make it work?" (in those manuals that I met, only the code in Qt was described, but whether it was necessary to put the database files in the project or somehow connect them was omitted).

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("TestName");//Требуется имя *.slq файла или имя модели БД?
    db.setUserName("root");
    db.setPassword("");
    bool ok = db.open();
    QMessageBox::about(nullptr, "Status", (ok) ? "True" : "False");

PS
If, due to my lack of experience, I mistakenly believe that this is possible with MySQL, then please advise the DBMS on which it is possible to implement the database as a separate file that could be accessed by the program on any computer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2015-01-23
@IvanFaQerstein

It looks like you need SQLite, not MySQL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question