qsqldatabase sqlite - how to set temp directory
-
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.
-
Hi,
Do you mean you would like to get a temporary directory from Qt to use with sqlite3_temp_directory ?
-
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.
-
Before going further on that, did you read the recommendations about not using that function unless you're using WinRT ?
-
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
-
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.
-
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.
-
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 :)
-
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...