[Qt-interest] How can I use sqlite3_trace with Qt?

Paul Dixon lordelph at gmail.com
Thu May 21 20:21:20 CEST 2009


I'm trying to diagnose some problems my app has with an sqlite database.

To this end, I'd like trace everything it does using sqlite3_trace
(see http://www.sqlite.org/c3ref/profile.html)

Given a QSqlDatabase instance, I'm getting an sqlite handle as follows:

        #include <sqlite3.h>

        QVariant v = m_db.driver()->handle();

        if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0)
        {
            sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
            if (handle != 0) {

              sqlite3_trace(handle, &sqliteTracer, NULL);
            }
         }

While this compiles, it won't link. I could link the program with
another copy libsqlite, but if I do that, it crashes, which wasn't
unexpected.

Anyone know how I can do this? Or other ways I could trace all the
sqlite activity?


Paul Dixon
http://blog.dixo.net



More information about the Qt-interest-old mailing list