QSqlDatabase open only existing database
Solved
General and Desktop
-
How to prevent Qt from creating an empty database file (in case of SQLITE driver), when i'm using
db.open()
? I want to show error and terminate application if it's root folder doesn't contain SQLite3 database file, else - open dbfile or show error if it is corrupted. -
Hi
its the default action of SQLite engine AFASIK.
You can just check yourself if file is in place#include <QFileInfo> bool fileExists(QString path) { QFileInfo check_file(path); // check if file exists and if yes: Is it really a file and no directory? return check_file.exists() && check_file.isFile(); }