mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user