PDA

View Full Version : data not being retained in sqlite DB



sticcino
1st July 2008, 22:46
Hello,

Strange problem occuring. I have a simple QTableView displaying an sqlite table. I can change the data in the table and the changes are sent to the database, but as soon as I exit out of the application and I look at the database table again, the data that was added/changed is not there :confused:, but while the app was running I could see the data with a separate db viewing utility.




model = new QSqlRelationalTableModel();

model->setTable(tableName);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setRelation(18, QSqlRelation("Category", "mCategoryID", "mCategoryName"));

model->select();

m_pMusicTableView->setModel(model);
m_pMusicTableView->hideColumn(0);

m_pMusicTableView->show();

...

void DlgLibraryEditor::submit()
{
model->database().transaction();
if (model->submitAll()) {
model->database().commit();
} else {
model->database().rollback();
QMessageBox::warning(this, tr("Library Manager"),
tr("The database reported an error: %1")
.arg(model->lastError().text()));
}
}


any insight greatly appreciated.

Thanks,
Johnny

janus
2nd July 2008, 10:38
Hi,

is there something like a sqlite journal file created? Then the data is stored temp due to a looked database. You should try to log the db errors. And I am not sure if the relationalmodel works at all because sqlite does not support primary keys.

lyuts
2nd July 2008, 10:42
Hi,

is there something like a sqlite journal file created? Then the data is stored temp due to a looked database. You should try to log the db errors. And I am not sure if the relationalmodel works at all because sqlite does not support primary keys.

You can make the relation model work by imlementing primary keys' functionality with triggers.