QSqlQuery query(db);qDebug() << "load extension res = " << query.exec(".load 'libSqliteIcu.so'; ");qDebug() << "error = " << query.lastError().text();qDebug() << "load collation res = " << query.exec("SELECT icu_load_collation('ru_RU', 'RUSSIAN')");qDebug() << "error = " << query.lastError().text();
QSqlDatabase db = ...; QVariant v = db.driver()->handle(); if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) { // v.data() returns a pointer to the handle sqlite3 *handle = *static_cast<sqlite3 **>(v.data()); if (handle != 0) { // check that it is not NULL ... } }
if( c=='l' && strncmp(azArg[0], "load", n)==0 && nArg>=2 ){ const char *zFile, *zProc; char *zErrMsg = 0; zFile = azArg[1]; zProc = nArg>=3 ? azArg[2] : 0; open_db(p); rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg); if( rc!=SQLITE_OK ){ fprintf(stderr, "Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } }
- libsqlite3-dev- sqlite3-0-dbg (необязательно)
wget www.sqlite.org/cvstrac/getfile?f=sqlite/ext/icu/icu.c -O icu.c
gcc -shared icu.c `icu-config --ldflags` -o libSqliteIcu.so
gcc -shared icu.c `icu-config --ldflags` -fPIC -o libSqliteIcu.so
...LIBS += -lsqlite3...
...#include <sqlite3ext.h>.../*После того как базу данных открыли пишем*/QVariant v = db.driver()->handle();if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) { sqlite3 *handle = *static_cast<sqlite3 **>(v.data()); if (handle != 0) { // check that it is not NULL int res = sqlite3_enable_load_extension(handle,1); if (res == SQLITE_OK) { res = sqlite3_load_extension(handle,"libSqliteIcu.so",0,0); if (res == SQLITE_OK) qDebug() << "Sqlite3 load ICU extension sucessfully"; else qDebug() << "Sqlite3 load ICU extension fail"; } else qDebug() << "Sqlite3 enable load extension fail"; }}...
res = sqlite3_load_extension(handle,"libSqliteIcu.dll",0,0);
TARGET = libSqliteIcuTEMPLATE = libCONFIG += shared releaseINCLUDEPATH += . \ include \ srcDEPENDPATH += include \ srcLIBS += -L./lib -licuin38 \ -L./lib -licuuc38 \ -L./lib -licudt38 \ -L./lib -licule38 \ -L./lib -liculx38 \ -L./lib -licutest \ -L./lib -licutu38HEADERS = sqliteicu.h \ sqlite3.h \ sqlite3ext.h \ unicode/utypes.h \ unicode/uregex.h \ unicode/ustring.h \ unicode/ucol.hSOURCES = icu.c \ sqlite3.c \ shell.c