{"record":{"id":"3f6e9acd8b9f9b56","repo":"SeaQL/sea-orm","slug":"not-sqlite-connection","errorCode":null,"errorMessage":"Not SQLite Connection","messagePattern":"Not SQLite Connection","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/database/db_connection.rs","lineNumber":808,"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":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/database/db_connection.rs#L790-L826","documentation":"get_sqlite_connection_pool() returns the underlying sqlx::SqlitePool. It panics when the inner connection is not SqlxSqlitePoolConnection — e.g. MySQL, Postgres, mock, proxy, rusqlite, or Disconnected. Note a rusqlite-backed connection also does not satisfy this; only the sqlx-sqlite pool does.","triggerScenarios":"Calling get_sqlite_connection_pool() on a connection created for another backend, on a MockDatabase or rusqlite connection, or a Disconnected connection.","commonSituations":"App connected to a server database but test/CLI code assumed SQLite; using the rusqlite feature and expecting this pool accessor to work; connect() failed leaving a Disconnected handle.","solutions":["Connect with a sqlite:// URL (sqlx-sqlite feature) before requesting the pool","Guard with get_database_backend() == DbBackend::Sqlite and confirm the connection is sqlx-backed, not rusqlite-backed","Handle connect() errors so a Disconnected connection never reaches pool access"],"exampleFix":"// before\nlet conn = Database::connect(\"postgres://...\").await?;\nlet pool = conn.get_sqlite_connection_pool(); // panics\n// after\nlet conn = Database::connect(\"sqlite://app.db?mode=rwc\").await?;\nlet pool = conn.get_sqlite_connection_pool(); // ok","handlingStrategy":"validation","validationCode":"assert_eq!(conn.get_database_backend(), DbBackend::Sqlite, \"raw pool access requires a sqlx SQLite connection\");\nlet pool = conn.get_sqlite_connection_pool();","typeGuard":"fn as_sqlite_pool(conn: &DatabaseConnection) -> Option<&sqlx::SqlitePool> {\n    (conn.get_database_backend() == DbBackend::Sqlite).then(|| conn.get_sqlite_connection_pool())\n}","tryCatchPattern":"let pool = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| conn.get_sqlite_connection_pool()));\nif pool.is_err() { return Err(anyhow!(\"not a sqlx SQLite connection\")); }","preventionTips":["Remember the rusqlite backend does NOT provide a sqlx SqlitePool; pick one SQLite feature and stick to it","Validate the sqlite:// URL at startup before using pool accessors","Assert the backend once at the point the pool is first needed"],"tags":["panic","sqlite","sqlx","connection-pool"],"backgroundTag":"type-mismatch","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"}