A
A
AlexSer2019-10-25 09:07:59
Qt
AlexSer, 2019-10-25 09:07:59

How to set up a database driver on QT creator?

Good day to all! Can you suggest steps to solve the problem with the database drivers on QT?
I have already reviewed a bunch of videos, tried all the instructions, but this "shaitan machine" always gives out "Driver not loaded".
main.cpp:
5db28f27492f0279916294.png
Why does it say that drivers are available, but at the same time that drivers are not loaded?

QSqlDatabase: QSQLite driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
"Driver not loaded Driver not loaded"

I thought I needed to compile the driver according to the instructions given in the help, but for some reason an error always comes out
Downloaded SQlite 3 sqlite3.dll to drive C:
5db290bb1aa88805886576.png
who knows, tell me, for the third day there is no shift.
QT version:5db2913cb8d40931512870.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ittakir, 2019-10-25
@AlexSer

For sqlite, you do not need to compile or put anything, everything should work out of the box.

db_ = QSqlDatabase::addDatabase("QSQLITE");
db_.setDatabaseName("mydatabase.db");
// db_.setConnectOptions("QSQLITE_OPEN_READONLY"); // Если нужно открыть в Read-only
db_.open();
// QSqlQuery q(db_);
// q.exec("PRAGMA foreign_keys = ON"); // Если нужны Foreign keys

They wrote to you: QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Use these driver names exactly as written, in capital letters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question