This code example below should help you a little, it shows how we install our own custom order by type. Hope this helps, feel free to ask more questions here and I'll help if I can.
void QtopiaSqlPrivate::installSorting( QSqlDatabase &db) { int sqliteLocaleAwareCompare(void *, int ll, const void *l, int rl, const void *r); QVariant v = db.driver()->handle(); if (v.isValid() && strcmp(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 int result = sqlite3_create_collation( handle, "localeAwareCompare", SQLITE_UTF16, // ANY would be nice, but we only encode in 16 anyway. 0, sqliteLocaleAwareCompare); if (result != SQLITE_OK) qLog(Sql) << "Could not add string collation function: " << result; } else { qLog(Sql) << "Could not get sqlite handle"; } } else { qLog(Sql) << "handle variant returned typename " << v.typeName(); } } Alexander Smondyrev wrote: > Hi, > > We are trying to figure out how to use Qt Sqlite driver to use loadable > extension mechanism. We have a shared library, which needs to be loaded > after db is open. We are using Qt classes to make a connection to > database, > so our code looks like this: > > QSqlDatabase db= QSqlDatabase::addDatabase("QSQLITE"); > db.setDatabaseName("./testDb"); > db.open(); > .................. > QSqlQuery query; > query.exec("SELECT load_extension('myextensionlib.so')"); > > This fails with an error message 'not authorized'. I understand that I > need > to enable load extension mechanism by calling > sqlite3_enable_load_extension(db, int 1) function, but since I use Qt > I dont > have db handle readily available. > > So, my question is whether there is another way to enable load extension > mechanism? Is it possible to enable it by default somehow so that I wont > have to call sqlite3_enable_load_extension function? I understand that > I can > build my extension into sqlite similar to fts1 and fts2, but I need to > load > it dynamically so this is not an option. > > Many thanks in advance for any suggestions. > > - Alex > -- Bill King, Software Engineer Trolltech, Brisbane Technology Park 26 Brandl St, Eight Mile Plains, QLD, Australia, 4113 Tel + 61 7 3219 9906 (x137) Fax + 61 7 3219 9938 mobile: 0423 532 733 ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------