Can not open SQLite-DB with full path
(1) By outdoor_guy on 2020-08-24 14:54:17 updated by 1.1 [link] [source]
I have the following code: <code> CListenController::~CListenController() { sqlite3_close(m_db); } bool CListenController::openDB(QString DBPath) { int rc = sqlite3_close(m_db); if (rc != SQLITE_OK) { return false; } m_db = nullptr; sqlite3 *db; rc = sqlite3_open_v2("file:///D:/QTTest/Zeitschriften/GEO_Register.db",&db,SQLITE_OPEN_READWRITE,NULL); if (rc != SQLITE_OK) { return false; } m_db = db; return true; } </code> In this case got back the rc = SQLITE_CANTOPEN(14) and the DB is not opened When debugging it, the problem seems to appear in sqlite3BtreeOpen(), and there in sqlite3PagerSetPagesize() Strange thing is: When I call the function the following way: <code> rc = sqlite3_open_v2("GEO_Register.db",&db,SQLITE_OPEN_READWRITE,NULL); </code> It opens the DB-File (this is the same DB-File) System: Windows 10, happens both with MSVC 2017 and MinGW. Using the Qt-Framework 5.12.9 SQLite Version: define SQLITE_VERSION "3.33.0" define SQLITE_VERSION_NUMBER 3033000 define SQLITE_SOURCE_ID "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f"
Can not open SQLite-DB with full path
(1.1) Originally by outdoor_guy with edits by Richard Hipp (drh) on 2020-08-24 15:26:24 from 1.0 updated by 1.2 [source]
<i>Originally by "outdoor_guy". Edited for formatting by "drh"</i> I have the following code: <verbatim> CListenController::~CListenController() { sqlite3_close(m_db); } bool CListenController::openDB(QString DBPath) { int rc = sqlite3_close(m_db); if (rc != SQLITE_OK) { return false; } m_db = nullptr; sqlite3 *db; rc = sqlite3_open_v2("file:///D:/QTTest/Zeitschriften/GEO_Register.db",&db,SQLITE_OPEN_READWRITE,NULL); if (rc != SQLITE_OK) { return false; } m_db = db; return true; } </verbatim> In this case got back the rc = SQLITE_CANTOPEN(14) and the DB is not opened When debugging it, the problem seems to appear in sqlite3BtreeOpen(), and there in sqlite3PagerSetPagesize() Strange thing is: When I call the function the following way: <verbatim> rc = sqlite3_open_v2("GEO_Register.db",&db,SQLITE_OPEN_READWRITE,NULL); </verbatim> It opens the DB-File (this is the same DB-File) <verbatim> System: Windows 10, happens both with MSVC 2017 and MinGW. Using the Qt-Framework 5.12.9 SQLite Version: define SQLITE_VERSION "3.33.0" define SQLITE_VERSION_NUMBER 3033000 define SQLITE_SOURCE_ID "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f" </verbatim>
Can not open SQLite-DB with full path
(1.2) Originally by outdoor_guy with edits by Richard Hipp (drh) on 2020-08-24 15:28:42 from 1.1 [link] [source]
Originally by "outdoor_guy". Edited for formatting by "drh"
I have the following code:
CListenController::~CListenController()
{
sqlite3_close(m_db);
}
bool CListenController::openDB(QString DBPath)
{
int rc = sqlite3_close(m_db);
if (rc != SQLITE_OK)
{
return false;
}
m_db = nullptr;
sqlite3 *db;
rc = sqlite3_open_v2("file:///D:/QTTest/Zeitschriften/GEO_Register.db",&db,SQLITE_OPEN_READWRITE,NULL);
if (rc != SQLITE_OK)
{
return false;
}
m_db = db;
return true;
}
In this case got back the rc = SQLITE_CANTOPEN(14) and the DB is not opened
When debugging it, the problem seems to appear in sqlite3BtreeOpen(), and there in sqlite3PagerSetPagesize()
Strange thing is: When I call the function the following way:
rc = sqlite3_open_v2("GEO_Register.db",&db,SQLITE_OPEN_READWRITE,NULL);
It opens the DB-File (this is the same DB-File)
System: Windows 10, happens both with MSVC 2017 and MinGW.
Using the Qt-Framework 5.12.9
SQLite Version:
define SQLITE_VERSION "3.33.0"
define SQLITE_VERSION_NUMBER 3033000
define SQLITE_SOURCE_ID "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f"
(2) By Clemens Ladisch (cladisch) on 2020-08-25 07:05:33 in reply to 1.2 [link] [source]
The documentation says:
URI filename interpretation is enabled if the SQLITE_OPEN_URI flag is set in the third argument to sqlite3_open_v2(), or if it has been enabled globally using the SQLITE_CONFIG_URI option with the sqlite3_config() method or by the SQLITE_USE_URI compile-time option. URI filename interpretation is turned off by default
(3) By outdoor_guy on 2020-08-25 07:41:42 in reply to 2 updated by 3.1 [link] [source]
That was the reason, thanks a lot Strangewise I read this documentation, but somehow completely overead "URI filename interpretation is turned off by default" May fault, of course, but maybe this should be put a little bit more prominent in the documentation (bold maybe), because I simply didn't expected such a behaviour. But anyway, problem is solved, so again thanks
(3.1) By outdoor_guy on 2020-08-25 08:20:03 edited from 3.0 in reply to 2 [link] [source]
That was the reason, thanks a lot
Strangewise I read this documentation, but somehow completely overread "URI filename interpretation is turned off by default"
My fault, of course, but maybe this should be put a little bit more prominent in the documentation (bold maybe), because I simply didn't expected such a behaviour.
But anyway, problem is solved, so again thanks
PS: The calling-line which works is (C/C++):
m_db = nullptr;
sqlite3 *db;
int rc = sqlite3_open_v2("file:///D:/QTTest/Zeitschriften/GEO_Register.db",&db,(SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI),NULL);