Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. SQLite APIs
Qt 6.11 is out! See what's new in the release blog

SQLite APIs

Scheduled Pinned Locked Moved 3rd Party Software
9 Posts 2 Posters 5.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmedalaa
    wrote on last edited by
    #1

    Can I use some of sqlite APIs like sqlite3_create_function from qt ??

    And If I can't do that I have another question,
    Can I link SQlite library in my qt project and use the same database handle in the library and qt sqlite calls ??

    Thanks in advance

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Great topic :) Have you tried the solution for using "same database handler for QSqlDatabase and sqlite3_create_function proposed at this thread from stackoverflow.com":http://stackoverflow.com/questions/6289623/using-sqlite-custom-functions-with-qt ?

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ahmedalaa
        wrote on last edited by
        #3

        Yes I use the same code their but it crash when I call sqlite3_create_function.
        I think it crashes in this line

        sqlite3_mutex_enter(db->mutex); in "sqlite3_create_function_v2" function sqlite3.c file
        when entering mutex

        and I checked the sqlite3* values in debug mode it seems to be rubbish data or wrong casting

        Hint : I used the same checks in the example and they all passed fine !!!!

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          [quote author="ahmedalaa" date="1363796613"]
          Hint : I used the same checks in the example and they all passed fine !!!![/quote]

          Btw on what platform and OS do you run your code?

          http://anavi.org/

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ahmedalaa
            wrote on last edited by
            #5

            I am on windows 7 x64 and building a 64 bit application on VS 2012 using Qt 4.8.4

            First I tried to use qt sqlite driver to link to these functions it gave me linking error
            then I compiled the sqlite 3.7 as a library and linked in my application it linked successfully

            and when I open the database with the sqlite APIs and don't use the qt handle of database it works fine
            but when I use the qt handle of the database it crashes as I told you before

            Question here can I link to those function using qt sqlite driver only? OR even can I use the qt database handle in call of another sqlite library?

            Thanks in advance :)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ahmedalaa
              wrote on last edited by
              #6

              I have succeeded to make it link using qt sqlite driver by rebuilding the driver and redefining SQLITE_API by Q_SQL_EXPORT to export sqlite APIs

              But it still crashes in the call of sqlite3_create_function

              @QVariant v = db.driver()->handle();
              // Create a handler and attach functions.
              sqlite3* handler = static_cast<sqlite3*>(v.data()); @

              I think this casting is done wrongly since I have checked its member values and it has undefined data inside mutex object and other members

              1 Reply Last reply
              0
              • L Offline
                L Offline
                leon.anavi
                wrote on last edited by
                #7

                [quote author="ahmedalaa" date="1363863748"]
                But it still crashes in the call of sqlite3_create_function
                [/quote]

                Check the described solution for a "similar issue atNokia Developer":http://bit.ly/YqFHeY

                bq. Ok i've resolved it!
                Simply the snippet code works well if embedded into code before sqlite3_create_function()...it doesn't work if it is wrapped into a function like below:
                sqlite * getDriver()
                {
                QT help code
                return (handle);
                }
                returned value is not null, but doesn't work

                http://anavi.org/

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ahmedalaa
                  wrote on last edited by
                  #8

                  Thanks for your reply,
                  but it worked with me with a different approach.
                  all the queries I want to do with the custom function I just did it using the sqlite3 APIs instead of QSqlDatabase

                  and about the redifinition of the Q_SQL_EXPORT to export sqlite APIs it doesn't work as I said before
                  I was linking the sqlite3 lib also with me (My mistake :( ) However it link successfully when I build the qt sqlite driver as static library and link it with me in the application.

                  I will try the other solution and inform you if it works with me or not.
                  Thank you for your help again :)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ahmedalaa
                    wrote on last edited by
                    #9

                    It also doesn't work, I think the crash comes from calling uninitialized function pointer "sqlite3GlobalConfig.mutex.xMutexEnter" however it is supposed to be initialized cause I have build the sqlite driver with SQLITE_THREADSAFE macro

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved