mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Rewrite and simplify import SQL code
Rewrite the import SQL code using a similar method to the one used in executeQuery(). This makes the code much easier to read and removes the last remnants of that C code stolen from some demo application.
This commit is contained in:
@@ -933,11 +933,19 @@ void MainWindow::importDatabaseFromSQL()
|
||||
if(!fileName.isNull())
|
||||
db.create(newDBfile);
|
||||
}
|
||||
int lineErr;
|
||||
if (!db.reload(fileName, &lineErr))
|
||||
QMessageBox::information(this, QApplication::applicationName(), tr("Error importing data at line %1").arg(lineErr) );
|
||||
|
||||
// Open, read, execute and close file
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
QFile f(fileName);
|
||||
f.open(QIODevice::ReadOnly);
|
||||
if(!db.executeMultiSQL(f.readAll()))
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error importing data: %1").arg(db.lastErrorMessage));
|
||||
else
|
||||
QMessageBox::information(this, QApplication::applicationName(), tr("Import completed"));
|
||||
QMessageBox::information(this, QApplication::applicationName(), tr("Import completed."));
|
||||
f.close();
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
// Resfresh window
|
||||
populateStructure();
|
||||
resetBrowser();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user