pythonsqlitezlibapsw

apsw.SQLError: SQLError: no such vfs: zipvfs when trying to read encrypted SQLite files on Windows using python & apsw


I have a code that works under linux and I am trying to port it to windows. It uses apsw to work with encrypted SQLite files.

flags = apsw.SQLITE_OPEN_READWRITE | apsw.SQLITE_OPEN_CREATE | apsw.SQLITE_OPEN_URI

connection_string = (
  "file:{filepath}?zv=zlib&level=9&vfs=zipvfs&password256={password}".format(
    filepath=filepath, password=password
  )
)

connection = apsw.Connection(connection_string, flags=flags)

when I try to run it under windows, it throws this error:

apsw.SQLError: SQLError: no such vfs: zipvfs

I have downloaded zlibwapi.dll and put it under System32, I have also tried building apsw from source

python setup.py fetch --all build --enable-all-extensions install

but I am still getting the error. (tried in python 3.10 and 3.11)


Solution

  • (Disclosure: I am the APSW author)

    ZipVFS is a separately licensed piece of software. That is why APSW can't download and include it when you requested everything to be fetched and all extensions enabled. As far as I can tell zlibwapi.dll is the compression routines only, and doesn't include the zipvfs code.

    You will need to do under Windows what you did under Linux to get zipvfs code included. At a minimum what should work is to create a sqlite3 directory where you have the APSW source, and in that sqlite3 directory place sqlite3-zipvfs.c named sqlite3.c. Then run your setup.py line again, but exclude the fetch bit. In the first few lines of output you will see something like this differing by the directory you are in.

    SQLite: Using amalgamation C:\projects\apsw\sqlite3\sqlite3.c