Skip to content

Types

bigint_type = DataType(int, 'BigInteger', 'sqlalchemy.types') module-attribute

The bigint_type variable is a shortcut for creating a DataType object that represents the int Python type and the BigInteger database type.

The pydantic_type attribute of the bigint_type variable is set to None.

bool_type = DataType(bool, 'Boolean', 'sqlalchemy.types') module-attribute

The bool_type variable is a shortcut for creating a DataType that represents the bool Python type and the Boolean database type.

The pydantic_type attribute of the bool_type variable is set to None.

date_only_type = DataType(date, 'Date', 'sqlalchemy.types') module-attribute

The date_only_type variable is a shortcut for creating a DataType object that represents the date Python type and the Date database type.

The pydantic_type attribute of the date_only_type variable is set to None.

date_time_type = DataType(datetime, 'DateTime', 'sqlalchemy.types') module-attribute

The date_time_type variable is a shortcut for creating a DataType that represents the datetime Python type and the DateTime database type.

The pydantic_type attribute of the date_time_type variable is set to None.

decimal_type = DataType(Decimal, 'Numeric', 'sqlalchemy.types') module-attribute

The decimal_type variable is a shortcut for creating a DataType object that represents the Decimal Python type and the Numeric database type.

The pydantic_type attribute of the decimal_type variable is set to None.

email_type = DataType(str, 'String', 'sqlalchemy.types', 'EmailStr') module-attribute

The email_type variable is a shortcut for creating a DataType object that represents the str Python type and the String database type.

The pydantic_type attribute of the email_type variable is set to EmailStr.

float_type = DataType(float, 'Float', 'sqlalchemy.types') module-attribute

The float_type variable is a shortcut for creating a DataType object that represents the float Python type and the Float database type.

The pydantic_type attribute of the float_type variable is set to None.

int_type = DataType(int, 'Integer', 'sqlalchemy.types') module-attribute

The int_type variable is a shortcut for creating a DataType object that represents the int Python type and the Integer database type.

The pydantic_type attribute of the int_type variable is set to None.

string_type = DataType(str, 'String', 'sqlalchemy.types') module-attribute

The string_type variable is a shortcut for creating a DataType object that represents the str Python type and the String database type.

The pydantic_type attribute of the string_type variable is set to None.

text_type = DataType(str, 'Text', 'sqlalchemy.types') module-attribute

The text_type variable is a shortcut for creating a DataType object that represents the str Python type and the Text database type.

The pydantic_type attribute of the text_type variable is set to None.

time_type = DataType(time, 'Time', 'sqlalchemy.types') module-attribute

The time_type variable is a shortcut for creating a DataType object that represents the time Python type and the Time database type.

The pydantic_type attribute of the time_type variable is set to None.

timedelta_type = DataType(timedelta, 'Interval', 'sqlalchemy.types') module-attribute

The timedelta_type variable is a shortcut for creating a DataType object that represents the timedelta Python type and the Interval database type.

The pydantic_type attribute of the timedelta_type variable is set to None.

unicode_type = DataType(str, 'Unicode', 'sqlalchemy.types') module-attribute

The unicode_type variable is a shortcut for creating a DataType object that represents the str Python type and the Unicode database type.

The pydantic_type attribute of the unicode_type variable is set to None.

DataType

Bases: BaseModel

DataType object used in fastapiez

Attributes:

Name Type Description
python_type str

The Python type of the data type.

python_module str

The module that the Python type belongs to.

db_type str

The database type of the data type.

db_module str

The module that the database type belongs to.

pydantic_type str

The Pydantic type of the data type.

Methods:

Name Description
add_pydantic_type

Adds the given Pydantic type to the data type.

Source code in warp_fastapi\data_types.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class DataType(BaseModel):
    """
    DataType object used in fastapiez

    Attributes:
        python_type (str): The Python type of the data type.
        python_module (str): The module that the Python type belongs to.
        db_type (str): The database type of the data type.
        db_module (str): The module that the database type belongs to.
        pydantic_type (str): The Pydantic type of the data type.

    Methods:
        add_pydantic_type(t): Adds the given Pydantic type to the data type.
    """

    python_type: str
    python_module: str
    db_type: str
    db_module: str
    pydantic_type: str | None = None

    def __init__(self, python_type: type, db_type: str, db_module: str, pydantic_type: str | None = None):
        """
        Initializes a new `DataType` instance.
        Args:
            python_type (type): The Python type of the data type.
            db_type (type): The database type of the data type.
            pydantic_type (type, optional): The Pydantic type of the data type. Defaults to None.
        """
        super().__init__(
            python_type=python_type.__name__,
            python_module=python_type.__module__,
            db_type=db_type,
            db_module=db_module,
        )
        if pydantic_type:
            self.add_pydantic_type(pydantic_type)

    def add_pydantic_type(self, t: str) -> None:
        """
        Adds the given Pydantic type to the data type.

        Args:
            t (type): The Pydantic type to add.
        """
        self.pydantic_type = t

__init__(python_type, db_type, db_module, pydantic_type=None)

Initializes a new DataType instance. Args: python_type (type): The Python type of the data type. db_type (type): The database type of the data type. pydantic_type (type, optional): The Pydantic type of the data type. Defaults to None.

Source code in warp_fastapi\data_types.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def __init__(self, python_type: type, db_type: str, db_module: str, pydantic_type: str | None = None):
    """
    Initializes a new `DataType` instance.
    Args:
        python_type (type): The Python type of the data type.
        db_type (type): The database type of the data type.
        pydantic_type (type, optional): The Pydantic type of the data type. Defaults to None.
    """
    super().__init__(
        python_type=python_type.__name__,
        python_module=python_type.__module__,
        db_type=db_type,
        db_module=db_module,
    )
    if pydantic_type:
        self.add_pydantic_type(pydantic_type)

add_pydantic_type(t)

Adds the given Pydantic type to the data type.

Parameters:

Name Type Description Default
t type

The Pydantic type to add.

required
Source code in warp_fastapi\data_types.py
45
46
47
48
49
50
51
52
def add_pydantic_type(self, t: str) -> None:
    """
    Adds the given Pydantic type to the data type.

    Args:
        t (type): The Pydantic type to add.
    """
    self.pydantic_type = t