exqlite
exqlite copied to clipboard
I can't seem to load a VFS
.. and it is making me sad.
I am not sure if the URI way of loading vfs, eg: database: "file://./bla.db?vfs=httpvfs" is enabled so it could work.
I tried just hacking in the vfs I wanted in the C code where sqlite3_open_v2 is called but that hasn't worked. It might be this VFS doing some crime, or not loading, or something.
But something is up. Trying to do this one: https://github.com/psanford/sqlite3vfshttp
For now you can try it with this URL:
export SQLITE3VFSHTTP_URL="https://fly.storage.tigris.dev/underjord-streaming-public/podcast-index.db"
My attempt
config :exqlite,
force_build: true,
load_extensions: [ "../sqlite3vfshttp/sqlite3http-ext/httpvfs"]
defmodule Podstream.DB do
def go do
{:ok, conn} = Exqlite.Sqlite3.open("./foo.db", mode: :readonly)
{:ok, statement} = Exqlite.Sqlite3.prepare(conn, "select * from podcasts limit 10")
:ok = Exqlite.Sqlite3.bind(conn, statement, [])
result = Exqlite.Sqlite3.step(conn, statement)
IO.inspect(result, label: "result")
end
end
// ..
rc = sqlite3_open_v2(filename, &db, flags, "httpvfs");
if (rc != SQLITE_OK) {
return make_error_tuple(env, "database_open_failed");
}
// ..
Forced mix deps.compile exqlite --force.
From SQLite docs:
The default VFS can be changed by registering or re-registering the VFS using the sqlite3_vfs_register() interface with a second parameter of 1. Hence, if a (unix) process wants to always use the "unix-nolock" VFS in place of "unix", the following code would work:
sqlite3_vfs_register(sqlite3_vfs_find("unix-nolock"), 1); An alternate VFS can also be specified as the 4th parameter to the sqlite3_open_v2() function. For example:
int rc = sqlite3_open_v2("demo.db", &db, SQLITE_OPEN_READWRITE, "unix-nolock"); Finally, if URI filenames have been enabled, then the alternative VFS can be specified using the "vfs=" parameter on the URI. This technique works with sqlite3_open(), sqlite3_open16(), sqlite3_open_v2(), and when a new database is ATTACH-ed to an existing database connection. For example:
ATTACH 'file:demo2.db?vfs=unix-none' AS demo2; The VFS specified by a URI has the highest priority. After that comes a VFS specified as the fourth argument to sqlite3_open_v2(). The default VFS is used if no VFS is specified otherwise.