I'm completely stuck with loading extensions in Qt's SQLite driver. I've done all steps from this 'how to'. Just changed SQLITE_ENABLE_LOAD_EXTENSION to DSQLITE_ENABLE_LOAD_EXTENSION.
After that I'm trying to run following code in my app:
QSqlQuery tSqlQuery;
QString sql_command_text;
sql_command_text = QString("SELECT load_extension(\"libspatialite-4.dll\")");
if(!tSqlQuery.exec(sql_command_text))
qDebug() << tSqlQuery.lastError().text();And qDebug gives me this: "not authorized Unable to fetch row".
I'm using Qt 4.6.3
What am I doing wrong? I've read tons of articles but couldn't find any solution.
You can be sure in following things:
Ok, as you suggested I tried to implement following code:QString dbName = dirPath->path() + "/roads.sqlite";sdb->setDatabaseName(dbName);if (!sdb->open()) {connection = false;return false;}QVariant v = sdb->driver()->handle();if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) {// v.data() returns a pointer to the handlesqlite3 *handle = *static_cast<sqlite3 **>(v.data());if (handle != 0) { // check that it is not NULLsqlite3_enable_load_extension(handle,1);}}
QString dbName = dirPath->path() + "/roads.sqlite";sdb->setDatabaseName(dbName);if (!sdb->open()) {connection = false;return false;}QVariant v = sdb->driver()->handle();if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) {// v.data() returns a pointer to the handlesqlite3 *handle = *static_cast<sqlite3 **>(v.data());if (handle != 0) { // check that it is not NULLsqlite3_enable_load_extension(handle,1);}}
QSqlQuery tSqlQuery("SELECT load_extension(\"libspatialite.dll\")", *sdb);
So, now sqlite's api function throws unhanded exception:SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){if( p ){sqlite3GlobalConfig.mutex.xMutexEnter(p); <----------- this line}}It seems to me that reason causes this errors (from my message before) is the same because it throws the same exception:First-chance exception at 0x00000000 in roadNetwork.exe: 0xC0000005: Access violation reading location 0x00000000.Unhandled exception at 0x00000000 in roadNetwork.exe: 0xC0000005: Access violation reading location 0x00000000.