SQLite User Forum

Can not open SQLite-DB with full path
Login

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 [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.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);