Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qsqldatabase sqlite - how to set temp directory
Forum Update on Monday, May 27th 2025

qsqldatabase sqlite - how to set temp directory

Scheduled Pinned Locked Moved Solved General and Desktop
qsqldatabasesqliteqt5.5c++
9 Posts 2 Posters 3.4k Views
  • 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.
  • P Offline
    P Offline
    phirestalker
    wrote on 27 Dec 2015, 21:16 last edited by phirestalker
    #1

    I would like to know what is the correct procedure in qt for getting the same result as setting sqlite3_temp_directory for programs directly using sqlite libraries.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Dec 2015, 23:16 last edited by
      #2

      Hi,

      Do you mean you would like to get a temporary directory from Qt to use with sqlite3_temp_directory ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        phirestalker
        wrote on 28 Dec 2015, 00:35 last edited by
        #3

        I would like to set sqlite3_temp_directory to a directory chosen by the user of my program, as per the documentation for sqlite, however I am not using the sqlite library directly I am using qt qsqldatabase. I want to know the equivalent setting in qt.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 28 Dec 2015, 00:38 last edited by
          #4

          Before going further on that, did you read the recommendations about not using that function unless you're using WinRT ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            phirestalker
            wrote on 28 Dec 2015, 00:53 last edited by phirestalker
            #5

            yes however short of fixing their mistake and compiling it myself, I need the temporary storage to be in a secure location.

            However I was hoping qt had a way of doing it differently

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Dec 2015, 22:58 last edited by
              #6

              Qt offers a standardized way to talk with databases. However, some special case needs custom handling. Your's is one of them. and you can get the handler.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Offline
                P Offline
                phirestalker
                wrote on 29 Dec 2015, 01:58 last edited by phirestalker
                #7

                I meant sqlite's mistake, and from a security standpoint not allowing users to choose a temp directory is a mistake.

                I found out about getting the handler, thanks for the tip.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 29 Dec 2015, 22:42 last edited by
                  #8

                  You're welcome !

                  Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    phirestalker
                    wrote on 30 Dec 2015, 02:02 last edited by
                    #9

                    for anyone else who wants to know how to do it, this is what I did.

                    add this to one of you header files

                    #include <sqlite3.h>
                    #include <QSqlDriver>
                    

                    add this to your .pro file

                    INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite
                    SOURCES += $$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite/sqlite3.c
                    

                    and in your MainWindow.cpp file add

                        sqlite3_temp_directory = path-to-dir;
                    

                    IMPORTANT
                    if you used homebrew to install qt5, they do NOT install the sources, you will have to downloaded the sources from the qt.io website extract and copy the qtbase/src folder to wherever $$[QT_INSTALL_PREFIX] is.

                    also this does compile, but I haven't tested to see if the files actually get stored where I set, so...

                    1 Reply Last reply
                    0

                    1/9

                    27 Dec 2015, 21:16

                    • Login

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