-
-
Notifications
You must be signed in to change notification settings - Fork 776
Description
Problem
SQLite extensions have the option to define multiple "entrypoints" in each loadable extension. For example, the upcoming version of sqlite-lines
will have 2 entrypoints: the default sqlite3_lines_init
(which SQLite will automatically guess for) and sqlite3_lines_noread_init
. The sqlite3_lines_noread_init
version omits functions that read from the filesystem, which is necessary for security purposes when running untrusted SQL (which Datasette does).
(Similar multiple entrypoints will also be added for sqlite-http).
The --load-extension
flag, however, doesn't give the option to specify a different entrypoint, so the default one is always used.
Proposal
I want there to be a new command line option of the --load-extension
flag to specify a custom entrypoint like so:
datasette my.db \
--load-extension ./lines0 sqlite3_lines0_noread_init
Then, under the hood, this line of code:
Line 562 in 7af67b5
conn.execute("SELECT load_extension(?)", [extension]) |
Would look something like this:
conn.execute("SELECT load_extension(?, ?)", [extension, entrypoint])
One potential problem: For backward compatibility, I'm not sure if Click allows cli flags to have variable number of options ("arity"). So I guess it could also use a :
delimiter like --static
:
datasette my.db \
--load-extension ./lines0:sqlite3_lines0_noread_init
Or maybe even a new flag name?
datasette my.db \
--load-extension-entrypoint ./lines0 sqlite3_lines0_noread_init
Personally I prefer the :
option... and maybe even --load-extension
-> --load
? Definitely out of scope for this issue tho
datasette my.db \
--load./lines0:sqlite3_lines0_noread_init