Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sqlite] supporting custom url open parameters added by extensions #3653

Open
chocological00 opened this issue Dec 22, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@chocological00
Copy link

chocological00 commented Dec 22, 2024

Is your feature request related to a problem? Please describe.
I'm trying to use the sqlite-zstd-vfs extension (which adds transparent zstd vfs on sqlite database files) with SQLx + sqlite3.

This plugin adds custom URL query parameters to the DB open call to tune compression-related parameters.

However, since SqliteConnectOptions does not allow attaching custom parameter name/values, I cannot set these options :(.

SqliteConnectOptions::from_str() also fails due to the static checks for allowed parameter names SQLx seems to be doing while parsing the provided string.

Describe the solution you'd like
Would it be possible to add a SqliteConnectOptions::other_params(&[(&'static str, String)]) or something similar to support passing in arbitrary values to open call?

Describe alternatives you've considered
sqlite-zstd-vfs by default uses 1 thread for (de-)compression, and &threads=n in the url params is the only way to control it.

Additional context
Also, currently, extension load happens after the connection is established, so I have to open a connection twice like below (otherwise vfs=zstd is not recognized):

// load plugin
let _ = SqliteConnectOptions::from_str("sqlite::memory:")
    .unwrap()
    .extension(connection.zstd_vfs_plugin_path)
    .connect()
    .await?;
let mut conn = SqliteConnectOptions::new()
    .filename("D:\\db.zsqlite3")
    .vfs("zstd")
    .connect()
    .await?;

(Would it be possible to load extension earlier so that we can do this in single connection?)

@chocological00 chocological00 added the enhancement New feature or request label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant