rwf2 / Rocket

A web framework for Rust.
https://rocket.rs
Other
23.59k stars 1.52k forks source link

Add SQLite extensions #2762

Closed priv2024 closed 1 month ago

priv2024 commented 2 months ago

What's missing?

I would like to load custom extensions to an SQLite database (such as fuzzy or vsv).

SQLx currently supports it, but I could not find a way to achieve that in the framework

Ideal Solution

In the init function as follow:

#[derive(Database)]
#[database("ship")]
pub struct Database(SqlitePool);

#[rocket::launch]
fn rocket() -> _ {
  rocket::build().attach(Database::init(&["trusted/sqlite/extension"]));
}

Why can't this be implemented outside of Rocket?

SQLx initialization, pool and connection is managed by Rocket itself, for which we do not have a way to configure the behavior.

Are there workarounds usable today?

I am looking for one.

Alternative Solutions

No response

Additional Context

No response

System Checks

SergioBenitez commented 2 months ago

SQLx currently supports it

Could you share the part of sqlx's docs that detail this support?

priv2024 commented 2 months ago

In SqliteConnectionOptions: https://docs.rs/sqlx/latest/sqlx/sqlite/struct.SqliteConnectOptions.html#method.extension