SeaQL/sea-orm · error
Not SQLite Connection
Error message
Not SQLite Connection
What it means
`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.
Source
Thrown at src/database/db_connection.rs:857
/// Panics if [DbConn] is not a Postgres connection.
#[cfg(feature = "sqlx-postgres")]
pub fn get_postgres_connection_pool(&self) -> &sqlx::PgPool {
match &self.inner {
DatabaseConnectionType::SqlxPostgresPoolConnection(conn) => &conn.pool,
_ => panic!("Not Postgres Connection"),
}
}
/// Get [sqlx::SqlitePool]
///
/// # Panics
///
/// Panics if [DbConn] is not a SQLite connection.
#[cfg(feature = "sqlx-sqlite")]
pub fn get_sqlite_connection_pool(&self) -> &sqlx::SqlitePool {
match &self.inner {
DatabaseConnectionType::SqlxSqlitePoolConnection(conn) => &conn.pool,
_ => panic!("Not SQLite Connection"),
}
}
}
impl DbBackend {
/// Check if the URI is the same as the specified database backend.
/// Returns true if they match.
///
/// # Panics
///
/// Panics if `base_url` cannot be parsed as `Url`.
pub fn is_prefix_of(self, base_url: &str) -> bool {
let base_url_parsed = Url::parse(base_url).expect("Fail to parse database URL");
match self {
Self::Postgres => {
base_url_parsed.scheme() == "postgres" || base_url_parsed.scheme() == "postgresql"
}
Self::MySql => base_url_parsed.scheme() == "mysql",View on GitHub (pinned to e29bcd1b41)
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.
Example fix
// before let pool = db.get_sqlite_connection_pool(); // panics unless sqlx SQLite // after debug_assert_eq!(db.get_database_backend(), DbBackend::Sqlite); let pool = db.get_sqlite_connection_pool();
Defensive patterns
Strategy: type-guard
Validate before calling
if conn.get_database_backend() != DbBackend::Sqlite {
return Err(anyhow!("get_sqlite_connection_pool requires a SQLite backend"));
} Type guard
fn as_sqlite_pool(conn: &DatabaseConnection) -> Option<&sqlx::SqlitePool> {
(conn.get_database_backend() == DbBackend::Sqlite)
.then(|| conn.get_sqlite_connection_pool())
} Try / catch
std::panic::catch_unwind(|| conn.get_sqlite_connection_pool()) // last resort; prefer backend check
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Not SQLite Connection
- Not MySQL Connection
- Not Postgres Connection
- Failed to get boolean
- Failed to get integer
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/58dd1560ba8a4a9b.
Report an issue: GitHub.