# Python : Database : Tortoise : Reference
## Imports
```python
tortoise.__all__ BaseDBAsyncClient Model Tortoise connections | run_async
tortoise.exceptions BaseORMException
ConfigurationError DBConnectionError DoesNotExist FieldError IncompleteInstanceError
IntegrityError MultipleObjectsReturned NotExistOrMultiple NoValuesFetched ObjectDoesNotExistError
OperationalError ParamsError TransactionManagementError UnSupportedError ValidationError
totrtoise.expressions Case F Q Subquery When
tortoise.fields.__all__
OnDelete CASCADE RESTRICT SET_DEFAULT SET_NULL NO_ACTION (str|Enum)
---
Field BigIntField BinaryField BooleanField CharEnumField CharField
DateField DatetimeField DecimalField FloatField IntEnumField IntField
JSONField SmallIntField TextField TimeDeltaField TimeField UUIDField
---
OneToOneField OneToOneRelation OneToOneNullableRelation BackwardOneToOneRelation
ForeignKeyField ForeignKeyRelation ForeignKeyNullableRelation BackwardFKRelation
ManyToManyField ManyToManyRelation ReverseRelation
tortoise.manager Manager
tortoise.queryset QuerySet
tortoise.transactions atomic, in_transaction
```
## Class Hierarchies
#### Backend
```python
BaseDBAsyncClient
BasePostgresClient
AsyncpgDBClient
BaseExecutor
BasePostgresExecutor
AsyncpgExecutor
BaseSchemaGenerator
BasePostgresSchemaGenerator
AsyncpgSchemaGenerator
```
#### Fields
```python
Field
IntField < int
BigIntField
SmallIntField
IntEnumFieldInstance
CharField
CharEnumFieldInstance
TextField < str
BooleanField
DecimalField < Decimal
DatetimeField < datetime
DateField < date
TimeField < time
TimeDeltaField
FloatField < float
JSONField < dict, list
UUIDField < UUID
BinaryField < bytes
---
RelationalField
ForeignKeyFieldInstance
OneToOneFieldInstance
BackwardFKRelation
BackwardOneToOneRelation
ManytoManyFieldInstance
ReverseRelation
ManytoManyRelation
```
#### Exceptions
```python
BaseORMException
ConfigurationError # the configuration of the ORM is invalid
DBConnectionError # problems with connecting to db
FieldError # there is a problem with a model field
OperationalError # an operational error occurs
IncompleteInstanceError # a partial model is attempted to be persisted
IntegrityError # there is an integrity error
NotExistOrMultiple( model, *args )
DoesNotExist( model, *args ) # expecting data, such as a `.get()` operation
# 'Object "{}" does not exist'
MultipleObjectsReturned( model, *args ) # doing a `.get()` operation, and more than one object is returned
# 'Multiple objects returned for "{}", expected exactly one'
NoValuesFetched # the related model was never fetched
ObjectDoesNotExistError # an item with the passed primary key does not exist
ParamsError # function can not be run with given parameters
TransactionManagementError # any transaction error occurs
UnSupportedError # operation is not supported
ValidationError # validators of field validate failed
```
## Field Attributes
```
field_type indexable SQL_TYPE AlGen GENERATED_SQL
────────────── ────────── ───────── ─────────── ───── ───────────────────────────────
IntField int True INT True SERIAL NOT NULL PRIMARY KEY
BigIntField int True BIGINT True BIGSERIAL NOT NULL PRIMARY KEY
SmallIntField int True SMALLINT True SMALLSERIAL NOT NULL PRIMARY KEY
CharField str True VARCHAR(ml) False None
TextField str False TEXT False None
BooleanField bool True BOOL False None
DecimalField Decimal True DECIMAL(md,dp) False None
DatetimeField datetime True TIMESTAMPTZ False None
DateField date True DATE False None
TimeField time True TIMETZ False None
TimeDeltaField timedelta True BIGINT False None
FloatField float True DOUBLE PRECISION False None
JSONField dict|list False JSONB False None
UUIDField UUID True UUID False None
BinaryField bytes False BYTEA False None
Special Logic & Limitations
────────────── ────────────────────────────────────────────────────────────
IntField if pk, set generated=True unless already set
CharField params: max_length
TextField disallowed: primary_key, unique, db_index
DecimalField params: max_digits, decimal_places
DatetimeField params: auto_now=False, auto_now_add=False
JSONField params: encoder=json.dumps, decoder=json.loads, field_type (optional)
UUIDField if pk and not default, default = uuid4
```