bool DBWorker::OpenDB() {
db.setHostName("localhost");
db.setDatabaseName("data");
db.setUserName("maryjane");
if (db.open() == false) {
qDebug() << "Error. Database not opened.";
return false;
}
...
QUERIES KINDA "CREATE TABLE ... IF NOT EXISTS"
...
return true;
}
DBWorker::~DBWorker() {
db.close()
}
bool DBWorker::OpenDB() {
db = QSqlDatabase::addDatabase("QSQLITE");
db.setHostName("localhost");
db.setDatabaseName("data");
db.setUserName("maryjane");
if (db.open() == false) {
qDebug() << "Error. Database not opened.";
return false;
}
...
QUERIES KINDA "CREATE TABLE ... IF NOT EXISTS"
...
return true;
}
DBWorker::~DBWorker() {
db.close()
}
To copy to clipboard, switch view to plain text mode
In other function i have inserting data. It's really inserting, 'cause when i'm closing application, db size are growing.
So, when i'm performing this instruction at the next application start
if (db.open() == false) {
if (db.open() == false) {
To copy to clipboard, switch view to plain text mode
db becomes clean.
Bookmarks