Add support for SQLite extension loading

Enable the extension support in SQLite.

Add code to allow loading of extension.

Add menu entry for easy extension loading.
This commit is contained in:
Martin Kleusberg
2013-05-03 15:26:34 +02:00
parent a031386edd
commit e36b17a485
7 changed files with 75 additions and 1 deletions

View File

@@ -81,6 +81,9 @@ bool DBBrowserDB::open ( const QString & db)
}
curDBFilename = db;
}
// Enable extension loading
sqlite3_enable_load_extension(_db, 1);
}
return ok;
@@ -1009,3 +1012,24 @@ bool DBBrowserDB::setPragma(const QString& pragma, int value, int& originalvalue
}
return false;
}
bool DBBrowserDB::loadExtension(const QString& filename)
{
// Check if file exists
if(!QFile::exists(filename))
{
lastErrorMessage = QObject::tr("File not found.");
return false;
}
// Try to load extension
char* error;
if(sqlite3_load_extension(_db, filename.toUtf8(), 0, &error) == SQLITE_OK)
{
return true;
} else {
lastErrorMessage = QString::fromUtf8(error);
sqlite3_free(error);
return false;
}
}