Exceptions¶
All errors inherit from TinyStoreError:
TinyStoreError
├── IntegrityError
│ ├── UniqueConstraintError
│ ├── ForeignKeyError
│ └── StaleDataError # optimistic-concurrency conflict
├── DoesNotExist
├── MultipleObjectsReturned
├── LockTimeoutError
├── TransactionError
├── SchemaError
├── RelationshipError
├── QueryError # incompatible-type comparisons, bad expressions
└── StorageError
Catch the specific ones you care about:
from tinystore import DoesNotExist, UniqueConstraintError
try:
db.get(User, 999)
except DoesNotExist:
...
exceptions
¶
Exception hierarchy for TinyStore.
All errors raised by TinyStore derive from :class:TinyStoreError, so callers can
catch any database failure with a single except clause.
TinyStoreError
¶
Bases: Exception
Base class for every TinyStore error.
IntegrityError
¶
Bases: TinyStoreError
A data-integrity constraint was violated.
UniqueConstraintError
¶
ForeignKeyError
¶
Bases: IntegrityError
A foreign-key reference is invalid or would orphan a row.
StaleDataError
¶
Bases: IntegrityError
The row was modified by another writer since it was loaded (optimistic concurrency).
DoesNotExist
¶
MultipleObjectsReturned
¶
LockTimeoutError
¶
Bases: TinyStoreError
The lock could not be acquired within the configured timeout.
TransactionError
¶
Bases: TinyStoreError
A transaction was used incorrectly (e.g. nested transactions).
SchemaError
¶
Bases: TinyStoreError
The on-disk schema is missing, incompatible, or corrupt.
QueryError
¶
Bases: TinyStoreError
A query expression is invalid (e.g. incompatible-type comparison).
RelationshipError
¶
Bases: TinyStoreError
A relationship could not be resolved (unknown name, ambiguous target, etc.).
StorageError
¶
Bases: TinyStoreError
The underlying storage layer reported a failure (I/O, corruption).