Exceptions#
Complete exception hierarchy for SQLSpec. All exceptions inherit from
SQLSpecError.
Base#
Configuration#
- class sqlspec.exceptions.ImproperConfigurationError[source]#
Bases:
SQLSpecErrorRaised when configuration is invalid or incomplete.
- class sqlspec.exceptions.ConfigResolverError[source]#
Bases:
SQLSpecErrorException raised when config resolution fails.
- class sqlspec.exceptions.MissingDependencyError[source]#
Bases:
SQLSpecErrorRaised when a required dependency is not installed.
Connection#
- class sqlspec.exceptions.DatabaseConnectionError[source]#
Bases:
SQLSpecErrorDatabase connection error (invalid credentials, network failure, etc.).
- class sqlspec.exceptions.ConnectionTimeoutError[source]#
Bases:
DatabaseConnectionErrorDatabase connection attempt timed out.
- Raised when:
TCP connection timeout to database server
DNS resolution timeout
SSL/TLS handshake timeout
Oracle connect timeout (ORA-12170)
- class sqlspec.exceptions.PermissionDeniedError[source]#
Bases:
DatabaseConnectionErrorDatabase access denied due to insufficient privileges.
- Raised when:
User lacks privileges for the operation (SQLSTATE 42501)
Invalid credentials provided (SQLSTATE 28000/28P01)
Database access denied (MySQL 1044/1045/1142)
Oracle insufficient privileges (ORA-01031)
Transaction#
- class sqlspec.exceptions.TransactionError[source]#
Bases:
SQLSpecErrorTransaction error (rollback, deadlock, serialization failure).
- class sqlspec.exceptions.SerializationConflictError[source]#
Bases:
TransactionErrorSerialization conflict (SQLSTATE 40001) requiring retry.
- class sqlspec.exceptions.TransactionRetryError[source]#
Bases:
TransactionErrorTransaction failed after retries were exhausted.
- class sqlspec.exceptions.DeadlockError[source]#
Bases:
TransactionErrorDeadlock detected during transaction execution.
- Raised when:
PostgreSQL deadlock detected (SQLSTATE 40P01)
MySQL deadlock detected (Error 1213)
Oracle deadlock detected (ORA-00060)
SQLite database locked (SQLITE_LOCKED)
Applications should typically retry the transaction when this error occurs.
Repository#
- class sqlspec.exceptions.RepositoryError[source]#
Bases:
SQLSpecErrorBase repository exception type.
- class sqlspec.exceptions.NotFoundError[source]#
Bases:
RepositoryErrorAn identity does not exist.
- class sqlspec.exceptions.MultipleResultsFoundError[source]#
Bases:
RepositoryErrorA single database result was required but more than one were found.
Integrity#
- class sqlspec.exceptions.IntegrityError[source]#
Bases:
RepositoryErrorData integrity error.
- class sqlspec.exceptions.UniqueViolationError[source]#
Bases:
IntegrityErrorA unique constraint was violated.
- class sqlspec.exceptions.ForeignKeyViolationError[source]#
Bases:
IntegrityErrorA foreign key constraint was violated.
- class sqlspec.exceptions.CheckViolationError[source]#
Bases:
IntegrityErrorA check constraint was violated.
- class sqlspec.exceptions.NotNullViolationError[source]#
Bases:
IntegrityErrorA not-null constraint was violated.
SQL Processing#
- class sqlspec.exceptions.SQLParsingError[source]#
Bases:
SQLSpecErrorIssues parsing SQL statements.
- class sqlspec.exceptions.SQLBuilderError[source]#
Bases:
SQLSpecErrorIssues Building or Generating SQL statements.
- class sqlspec.exceptions.SQLConversionError[source]#
Bases:
SQLSpecErrorIssues converting SQL statements.
- class sqlspec.exceptions.DialectNotSupportedError[source]#
Bases:
SQLBuilderErrorRaised when a SQL dialect does not support a specific feature.
Execution#
- class sqlspec.exceptions.OperationalError[source]#
Bases:
SQLSpecErrorOperational database error (timeout, disk full, resource limit).
- class sqlspec.exceptions.QueryTimeoutError[source]#
Bases:
OperationalErrorQuery execution exceeded a timeout or deadline.
- Raised when:
Lock wait timeout exceeded (MySQL 1205)
Statement or service deadline exceeded
- class sqlspec.exceptions.OperationCancelledError[source]#
Bases:
OperationalErrorDatabase operation was explicitly cancelled by a caller or operator.
OperationCancelledError and QueryTimeoutError are sibling operational
errors. Catch OperationCancelledError for explicit caller or operator
cancellation, and QueryTimeoutError for elapsed statement timeouts and
deadlines. ADBC CANCELLED and TIMEOUT statuses follow this distinction.
Callers that previously caught QueryTimeoutError for cancellation should
catch both exceptions during migration, or catch OperationalError when the
distinction is not relevant.
- class sqlspec.exceptions.DataError[source]#
Bases:
SQLSpecErrorInvalid data type or format for database operation.
- class sqlspec.exceptions.StackExecutionError[source]#
Bases:
SQLSpecErrorRaised when a statement stack operation fails.
Storage#
- class sqlspec.exceptions.StorageOperationFailedError[source]#
Bases:
SQLSpecErrorRaised when a storage backend operation fails.
- class sqlspec.exceptions.StorageCapabilityError[source]#
Bases:
SQLSpecErrorRaised when a requested storage bridge capability is unavailable.
- class sqlspec.exceptions.FileNotFoundInStorageError[source]#
Bases:
StorageOperationFailedErrorRaised when a file or object is not found in the storage backend.
SQL Files#
- class sqlspec.exceptions.SQLFileNotFoundError[source]#
Bases:
SQLSpecErrorRaised when a SQL file cannot be found.
- class sqlspec.exceptions.SQLStatementNotFoundError[source]#
Bases:
SQLFileNotFoundErrorRaised when a named SQL statement is not loaded.
- class sqlspec.exceptions.SQLFileParseError[source]#
Bases:
SQLSpecErrorRaised when a SQL file cannot be parsed.
Migration#
- class sqlspec.exceptions.MigrationError[source]#
Bases:
SQLSpecErrorBase exception for migration-related errors.
- class sqlspec.exceptions.OutOfOrderMigrationError[source]#
Bases:
MigrationErrorRaised when an out-of-order migration is detected in strict mode.
Out-of-order migrations occur when a pending migration has a timestamp earlier than already-applied migrations, typically from late-merging branches.
- class sqlspec.exceptions.SquashValidationError[source]#
Bases:
MigrationErrorRaised when migration squash validation fails.
- Squash validation errors occur when:
Version range is invalid (start > end)
Gap detected in version sequence
Mixed migration types that cannot be squashed
Target file already exists
Events#
- class sqlspec.exceptions.EventChannelError[source]#
Bases:
SQLSpecErrorRaised when event channel operations fail.
Inheritance Tree#
SQLSpecError
+-- ImproperConfigurationError
+-- ConfigResolverError
+-- MissingDependencyError
+-- EventChannelError
+-- SQLParsingError
+-- SQLBuilderError
| +-- DialectNotSupportedError
+-- SQLConversionError
+-- DatabaseConnectionError
| +-- PermissionDeniedError
| +-- ConnectionTimeoutError
+-- TransactionError
| +-- SerializationConflictError
| +-- TransactionRetryError
| +-- DeadlockError
+-- RepositoryError
| +-- NotFoundError
| +-- MultipleResultsFoundError
| +-- IntegrityError
| +-- UniqueViolationError
| +-- ForeignKeyViolationError
| +-- CheckViolationError
| +-- NotNullViolationError
+-- DataError
+-- OperationalError
| +-- QueryTimeoutError
| +-- OperationCancelledError
+-- StackExecutionError
+-- StorageOperationFailedError
| +-- FileNotFoundInStorageError
+-- StorageCapabilityError
+-- SQLFileNotFoundError
| +-- SQLStatementNotFoundError
+-- SQLFileParseError
+-- MigrationError
+-- OutOfOrderMigrationError
+-- SquashValidationError