Results 1 to 2 of 2

Thread: Qt SQLite user functions

  1. #1
    Join Date
    Oct 2008
    Location
    Germany
    Posts
    29
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt SQLite user functions

    Hi,

    i'm developing a program that can use multiple databases (PosgreSQL, MySQL, SQLite).
    In some of the queries I need to use user functions like to_char, lpad ... which aren't supported by SQLite.
    However I read that it's possible to add user functions to SQLite.
    Is this also possiple in SQLite as used in Qt?

  2. #2
    Join Date
    Oct 2008
    Location
    Germany
    Posts
    29
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt SQLite user functions

    Well it works using SQLite extensions.
    But - to enable the use of extensions I have to call sqlite3_enable_load_extension. This doesn't work. The app always crashes when calling sqlite3_enable_load_extension(handle,1).
    Did I make a mistake?

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::database();
    2. QVariant v = db.driver()->handle();
    3. if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) {
    4. // v.data() returns a pointer to the handle
    5. sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
    6. if (handle != 0) { // check that it is not NULL
    7. sqlite3_enable_load_extension(handle,1);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Logging Qt User Actions
    By Frank J. Lhota in forum Qt Programming
    Replies: 14
    Last Post: 30th May 2014, 21:36
  2. Dynamically add functions to qt program
    By sincnarf in forum Qt Programming
    Replies: 31
    Last Post: 22nd September 2007, 03:55
  3. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.