{"record":{"id":"58dd1560ba8a4a9b","repo":"SeaQL/sea-orm","slug":"not-sqlite-connection-58dd15","errorCode":null,"errorMessage":"Not SQLite Connection","messagePattern":"Not SQLite Connection","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/database/db_connection.rs","lineNumber":857,"sourceCode":"    /// Panics if [DbConn] is not a Postgres connection.\n    #[cfg(feature = \"sqlx-postgres\")]\n    pub fn get_postgres_connection_pool(&self) -> &sqlx::PgPool {\n        match &self.inner {\n            DatabaseConnectionType::SqlxPostgresPoolConnection(conn) => &conn.pool,\n            _ => panic!(\"Not Postgres Connection\"),\n        }\n    }\n\n    /// Get [sqlx::SqlitePool]\n    ///\n    /// # Panics\n    ///\n    /// Panics if [DbConn] is not a SQLite connection.\n    #[cfg(feature = \"sqlx-sqlite\")]\n    pub fn get_sqlite_connection_pool(&self) -> &sqlx::SqlitePool {\n        match &self.inner {\n            DatabaseConnectionType::SqlxSqlitePoolConnection(conn) => &conn.pool,\n            _ => panic!(\"Not SQLite Connection\"),\n        }\n    }\n}\n\nimpl DbBackend {\n    /// Check if the URI is the same as the specified database backend.\n    /// Returns true if they match.\n    ///\n    /// # Panics\n    ///\n    /// Panics if `base_url` cannot be parsed as `Url`.\n    pub fn is_prefix_of(self, base_url: &str) -> bool {\n        let base_url_parsed = Url::parse(base_url).expect(\"Fail to parse database URL\");\n        match self {\n            Self::Postgres => {\n                base_url_parsed.scheme() == \"postgres\" || base_url_parsed.scheme() == \"postgresql\"\n            }\n            Self::MySql => base_url_parsed.scheme() == \"mysql\",","sourceCodeStart":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/database/db_connection.rs#L839-L875","documentation":"`get_sqlite_connection_pool()` returns the inner `sqlx::SqlitePool` only when the connection is a `SqlxSqlitePoolConnection`; every other backend panics with \"Not SQLite Connection\". As with the MySQL/Postgres variants, this is a deliberately strict accessor for engine-specific access.","triggerScenarios":"Calling `db.get_sqlite_connection_pool()` (or methods on the SQLite path such as `as_str` that assume SQLite) when the handle wraps MySQL, Postgres, mock, or a disconnected connection.","commonSituations":"Generic repository code calling SQLite-specific pool APIs; test fixtures wired to the mock backend; env config switched from SQLite to another engine without updating code.","solutions":["Check `db.get_database_backend() == DbBackend::Sqlite` before calling the accessor.","Fix the connection URI so it targets SQLite (`sqlite://...`) if SQLite was intended.","Refactor to backend-generic SeaORM APIs instead of extracting the engine-specific pool.","For rusqlite-shared connections, note this getter only covers the sqlx-sqlite feature path."],"exampleFix":"// before\nlet pool = db.get_sqlite_connection_pool(); // panics unless sqlx SQLite\n\n// after\ndebug_assert_eq!(db.get_database_backend(), DbBackend::Sqlite);\nlet pool = db.get_sqlite_connection_pool();","handlingStrategy":"type-guard","validationCode":"if conn.get_database_backend() != DbBackend::Sqlite {\n    return Err(anyhow!(\"get_sqlite_connection_pool requires a SQLite backend\"));\n}","typeGuard":"fn as_sqlite_pool(conn: &DatabaseConnection) -> Option<&sqlx::SqlitePool> {\n    (conn.get_database_backend() == DbBackend::Sqlite)\n        .then(|| conn.get_sqlite_connection_pool())\n}","tryCatchPattern":"std::panic::catch_unwind(|| conn.get_sqlite_connection_pool()) // last resort; prefer backend check","preventionTips":["Verify backend is Sqlite before extracting the pool.","Keep the sqlite:// URI in a dedicated dev/test config.","Use backend-generic SeaORM APIs in shared code paths.","Document which methods require which engine at the module level."],"tags":["panic","sqlite","wrong-backend","sqlx"],"backgroundTag":"incompatible-source-type","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}