{"record":{"id":"e803a9cbe994e501","repo":"transact-rs/sqlx","slug":"no-drivers-installed-please-see-the-documentation","errorCode":null,"errorMessage":"No drivers installed. Please see the documentation in `sqlx::any` for details.","messagePattern":"No drivers installed\\. Please see the documentation in `sqlx::any` for details\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sqlx-core/src/any/driver.rs","lineNumber":147,"sourceCode":"pub fn install_drivers(\n    drivers: &'static [AnyDriver],\n) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {\n    DRIVERS\n        .set(drivers)\n        .map_err(|_| \"drivers already installed\".into())\n}\n\n#[cfg(feature = \"migrate\")]\npub(crate) fn from_url_str(url: &str) -> crate::Result<&'static AnyDriver> {\n    from_url(&url.parse().map_err(Error::config)?)\n}\n\npub(crate) fn from_url(url: &Url) -> crate::Result<&'static AnyDriver> {\n    let scheme = url.scheme();\n\n    let drivers: &[AnyDriver] = DRIVERS\n        .get()\n        .expect(\"No drivers installed. Please see the documentation in `sqlx::any` for details.\");\n\n    drivers\n        .iter()\n        .find(|driver| driver.url_schemes.contains(&url.scheme()))\n        .ok_or_else(|| {\n            Error::Configuration(format!(\"no driver found for URL scheme {scheme:?}\").into())\n        })\n}\n","sourceCodeStart":129,"sourceCodeEnd":156,"githubUrl":"https://github.com/transact-rs/sqlx/blob/03af8bcc5711a1935580a54bea249c219a0c217d/sqlx-core/src/any/driver.rs#L129-L156","documentation":"`sqlx::any::AnyDriver::from_url` looks up installed drivers in a lazily-initialized registry (`DRIVERS`). If the registry was never populated, `.get()` panics with this message; this happens when no `sqlx-*` driver crates are registered because the `any` driver feature flags were not enabled. sqlx requires opting in to drivers via feature flags such as `sqlx = { features = [\"any\", \"postgres\"] }`.","triggerScenarios":"Using `AnyPool::connect(url)` / `AnyConnection` / `AnyDriver::from_url_str` with a URL like `postgres://...` or `sqlite://...` while the corresponding driver feature (`postgres`, `mysql`, `sqlite`) is not enabled in the `sqlx` dependency, so `install_default_drivers` never ran.","commonSituations":"Switching an app to `sqlx::any` for runtime-selectable backends but forgetting to add the concrete driver features; workspace builds where `any` is enabled in one crate but driver features are not propagated (features are additive per-crate, so they must be enabled on the same `sqlx` dependency that has `any` enabled somewhere in the graph).","solutions":["Enable the `any` feature together with the concrete driver features on the sqlx dependency: `sqlx = { version = \"...\", features = [\"any\", \"postgres\"] }`.","Ensure the concrete driver feature is enabled in the same crate that depends on `sqlx` with `any` (Cargo features are per-crate and unify, but at least one crate in the graph must combine them).","If constructing `AnyDriver` manually, call `sqlx_any::install_default_drivers()` (or register your driver) before `from_url_str`.","Verify with `cargo tree -e features -p sqlx` that the driver feature is actually active in your build."],"exampleFix":"// before (Cargo.toml)\nsqlx = { version = \"0.8\", features = [\"any\"] }\nlet pool = AnyPool::connect(\"postgres://localhost/app\").await?; // panics: no drivers\n\n// after (Cargo.toml)\nsqlx = { version = \"0.8\", features = [\"any\", \"postgres\", \"sqlite\"] }\nlet pool = AnyPool::connect(\"postgres://localhost/app\").await?;","handlingStrategy":"validation","validationCode":"// compile-time: assert driver features are enabled\n#[cfg(not(any(feature = \"postgres\", feature = \"mysql\", feature = \"sqlite\")))]\ncompile_error!(\"sqlx `any` usage requires at least one concrete driver feature\");","typeGuard":"fn scheme_is_supported(url: &str) -> bool {\n    matches!(\n        url.split(\":\").next(),\n        Some(\"postgres\") | Some(\"postgresql\") | Some(\"mysql\") | Some(\"mariadb\") | Some(\"sqlite\")\n    )\n}","tryCatchPattern":"// with manual driver installation, catch a panic from an empty registry\nlet result = std::panic::catch_unwind(|| {\n    tokio::runtime::Handle::current().block_on(AnyPool::connect(url))\n});\nmatch result {\n    Ok(Ok(pool)) => pool,\n    Ok(Err(e)) => return Err(e.into()),\n    Err(_) => panic!(\"AnyDriver registry empty: enable sqlx features [any, postgres|mysql|sqlite]\"),\n}","preventionTips":["Always co-enable `any` with the concrete driver features on the same sqlx dependency.","Use `cargo tree -e features -p sqlx` in CI to assert driver features are active.","If using `AnyDriver` directly, call `install_default_drivers()` (or your installer) once in `main` before any pool creation.","Prefer `AnyPool::connect` over manual `from_url_str` so error paths stay uniform."],"tags":["rust","sqlx","any-driver","feature-flags","configuration"],"backgroundTag":"no-driver-installed-for-scheme","analyzedSha":"03af8bcc5711a1935580a54bea249c219a0c217d","analyzedAt":"2026-09-03T15:01:28.752Z","contentChangedAt":"2026-09-03T15:01:28.752Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}