class TypeEngine(Visitable, Generic[
Known subclasses: sqlalchemy.dialects.mssql.MONEY
, sqlalchemy.dialects.mssql.SMALLMONEY
, sqlalchemy.dialects.mssql.SQL_VARIANT
, sqlalchemy.dialects.mysql.BIT
, sqlalchemy.dialects.mysql.YEAR
, sqlalchemy.dialects.oracle.ROWID
, sqlalchemy.dialects.postgresql.BIT
, sqlalchemy.dialects.postgresql.CIDR
, sqlalchemy.dialects.postgresql.hstore.HSTORE
, sqlalchemy.dialects.postgresql.INET
, sqlalchemy.dialects.postgresql.MACADDR
, sqlalchemy.dialects.postgresql.MACADDR8
, sqlalchemy.dialects.postgresql.MONEY
, sqlalchemy.dialects.postgresql.NamedType
, sqlalchemy.dialects.postgresql.OID
, sqlalchemy.dialects.postgresql.ranges.AbstractRange
, sqlalchemy.dialects.postgresql.REGCLASS
, sqlalchemy.dialects.postgresql.REGCONFIG
, sqlalchemy.dialects.postgresql.TSQUERY
, sqlalchemy.dialects.postgresql.TSVECTOR
, sqlalchemy.sql.sqltypes.ARRAY
, sqlalchemy.sql.sqltypes.Boolean
, sqlalchemy.sql.sqltypes.Date
, sqlalchemy.sql.sqltypes.DateTime
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Integer
, sqlalchemy.sql.sqltypes.JSON
, sqlalchemy.sql.sqltypes.JSON.JSONElementType
, sqlalchemy.sql.sqltypes.NullType
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.TableValueType
, sqlalchemy.sql.sqltypes.Time
, sqlalchemy.sql.sqltypes.TupleType
, sqlalchemy.sql.sqltypes.Uuid
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.sql.type_api.UserDefinedType
, sqlalchemy.sql.sqltypes._AbstractInterval
, sqlalchemy.sql.sqltypes._Binary
The ultimate base class for all SQL datatypes. Common subclasses of :class:`.TypeEngine` include :class:`.String`, :class:`.Integer`, and :class:`.Boolean`. For an overview of the SQLAlchemy typing system, see :ref:`types_toplevel`. .. seealso:: :ref:`types_toplevel`
Class |
|
Base class for custom comparison operations defined at the type level. See :attr:`.TypeEngine.comparator_factory`. |
Method | __repr__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | adapt |
Produce an "adapted" form of this type, given an "impl" class to work with. |
Method | as |
Return an instance of the generic type corresponding to this type using heuristic rule. The method may be overridden if this heuristic rule is not sufficient. |
Method | bind |
Given a bind value (i.e. a :class:`.BindParameter` instance), return a SQL expression in its place. |
Method | bind |
Return a conversion function for processing bind values. |
Method | coerce |
Suggest a type for a 'coerced' Python value in an expression. |
Method | column |
Given a SELECT column expression, return a wrapping SQL expression. |
Method | compare |
Compare this type against the given backend type. |
Method | compare |
Compare two values for equality. |
Method | compile |
Produce a string-compiled form of this :class:`.TypeEngine`. |
Method | copy |
Undocumented |
Method | copy |
Undocumented |
Method | dialect |
Return a dialect-specific implementation for this :class:`.TypeEngine`. |
Method | evaluates |
Return a copy of this type which has the :attr:`.should_evaluate_none` flag set to True. |
Method | get |
Return the corresponding type object from the underlying DB-API, if any. |
Method | literal |
Return a conversion function for processing literal values that are to be rendered directly without using binds. |
Method | result |
Return a conversion function for processing result row values. |
Method | with |
Produce a copy of this type object that will utilize the given type when applied to the dialect of the given name. |
Class Variable | hashable |
Flag, if False, means values from this type aren't hashable. |
Class Variable | render |
Render bind casts for :attr:`.BindTyping.RENDER_CASTS` mode. |
Class Variable | render |
render casts when rendering a value as an inline literal, e.g. with :meth:`.TypeEngine.literal_processor`. |
Class Variable | should |
If True, the Python constant ``None`` is considered to be handled explicitly by this type. |
Class Variable | sort |
A sorting function that can be passed as the key to sorted. |
Property | python |
Return the Python type object expected to be returned by instances of this type, if known. |
Static Method | _to |
Undocumented |
Method | _cached |
Return a dialect-specific bind processor for this type. |
Method | _cached |
return a dialect-specific processing object for custom purposes. |
Method | _cached |
Return a dialect-specific literal processor for this type. |
Method | _cached |
Return a dialect-specific result processor for this type. |
Method | _compare |
Undocumented |
Method | _default |
Undocumented |
Method | _dialect |
Return a dialect-specific registry which caches a dialect-specific implementation, bind processing function, and one or more result processing functions. |
Method | _gen |
Undocumented |
Method | _resolve |
adjust this type given a literal Python value that will be stored in a bound parameter. |
Method | _resolve |
given a Python type (e.g. ``int``, ``str``, etc. ) return an instance of this :class:`.TypeEngine` that's appropriate for this type. |
Method | _unwrapped |
Return the 'unwrapped' dialect impl for this type. |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _isnull |
Undocumented |
Class Variable | _sqla |
Undocumented |
Property | _generic |
Undocumented |
Property | _has |
memoized boolean, check if bind_expression is implemented. |
Property | _has |
memoized boolean, check if column_expression is implemented. |
Property | _static |
Undocumented |
Property | _type |
Return a rudimental 'affinity' value expressing the general class of type. |
Inherited from Visitable
:
Method | __class |
Undocumented |
Method | __init |
Undocumented |
Class Variable | __slots__ |
Undocumented |
Class Variable | __visit |
Undocumented |
Class Method | _generate |
Undocumented |
Method | _compiler |
Undocumented |
Class Variable | _original |
Undocumented |
sqlalchemy.dialects.mysql.SET
, sqlalchemy.dialects.oracle.NUMBER
, sqlalchemy.dialects.oracle.NUMBER
, sqlalchemy.dialects.postgresql.ranges.AbstractRange
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Enum
Produce an "adapted" form of this type, given an "impl" class to work with. This method is used internally to associate generic types with "implementation" types that are specific to a particular dialect.
sqlalchemy.dialects.oracle.INTERVAL
, sqlalchemy.dialects.postgresql.INTERVAL
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Enum
Return an instance of the generic type corresponding to this type using heuristic rule. The method may be overridden if this heuristic rule is not sufficient. >>> from sqlalchemy.dialects.mysql import INTEGER >>> INTEGER(display_width=4).as_generic() Integer() >>> from sqlalchemy.dialects.mysql import NVARCHAR >>> NVARCHAR(length=100).as_generic() Unicode(length=100) .. versionadded:: 1.4.0b2 .. seealso:: :ref:`metadata_reflection_dbagnostic_types` - describes the use of :meth:`_types.TypeEngine.as_generic` in conjunction with the :meth:`_sql.DDLEvents.column_reflect` event, which is its intended use.
sqlalchemy.sql.type_api.TypeDecorator
Given a bind value (i.e. a :class:`.BindParameter` instance), return a SQL expression in its place. This is typically a SQL function that wraps the existing bound parameter within the statement. It is used for special data types that require literals being wrapped in some special database function in order to coerce an application-level value into a database-specific format. It is the SQL analogue of the :meth:`.TypeEngine.bind_processor` method. This method is called during the **SQL compilation** phase of a statement, when rendering a SQL string. It is **not** called against specific values. Note that this method, when implemented, should always return the exact same structure, without any conditional logic, as it may be used in an executemany() call against an arbitrary number of bound parameter sets. .. note:: This method is only called relative to a **dialect specific type object**, which is often **private to a dialect in use** and is not the same type object as the public facing one, which means it's not feasible to subclass a :class:`.types.TypeEngine` class in order to provide an alternate :meth:`_types.TypeEngine.bind_expression` method, unless subclassing the :class:`_types.UserDefinedType` class explicitly. To provide alternate behavior for :meth:`_types.TypeEngine.bind_expression`, implement a :class:`_types.TypeDecorator` class and provide an implementation of :meth:`_types.TypeDecorator.bind_expression`. .. seealso:: :ref:`types_typedecorator` .. seealso:: :ref:`types_sql_value_processing`
sqlalchemy.dialects.mssql.TIME
, sqlalchemy.dialects.postgresql.ARRAY
, sqlalchemy.dialects.postgresql.hstore.HSTORE
, sqlalchemy.dialects.sqlite.DATE
, sqlalchemy.dialects.sqlite.DATETIME
, sqlalchemy.dialects.sqlite.TIME
, sqlalchemy.sql.sqltypes.Boolean
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Interval
, sqlalchemy.sql.sqltypes.JSON
, sqlalchemy.sql.sqltypes.JSON.JSONElementType
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.Uuid
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.dialects.mssql.base._MSDate
, sqlalchemy.dialects.oracle.cx_oracle._CXOracleDate
, sqlalchemy.dialects.postgresql.asyncpg._AsyncpgMultiRange
, sqlalchemy.dialects.postgresql.asyncpg._AsyncpgMultiRange
, sqlalchemy.dialects.postgresql.asyncpg._AsyncpgRange
, sqlalchemy.dialects.postgresql.psycopg._PsycopgMultiRange
, sqlalchemy.dialects.postgresql.psycopg._PsycopgMultiRange
, sqlalchemy.dialects.postgresql.psycopg._PsycopgRange
, sqlalchemy.dialects.postgresql.psycopg2._Psycopg2Range
, sqlalchemy.sql.sqltypes._Binary
Return a conversion function for processing bind values. Returns a callable which will receive a bind parameter value as the sole positional argument and will return a value to send to the DB-API. If processing is not necessary, the method should return ``None``. .. note:: This method is only called relative to a **dialect specific type object**, which is often **private to a dialect in use** and is not the same type object as the public facing one, which means it's not feasible to subclass a :class:`.types.TypeEngine` class in order to provide an alternate :meth:`_types.TypeEngine.bind_processor` method, unless subclassing the :class:`_types.UserDefinedType` class explicitly. To provide alternate behavior for :meth:`_types.TypeEngine.bind_processor`, implement a :class:`_types.TypeDecorator` class and provide an implementation of :meth:`_types.TypeDecorator.process_bind_param`. .. seealso:: :ref:`types_typedecorator` :param dialect: Dialect instance in use.
Optional[ OperatorType]
, value: Any
) -> TypeEngine[ Any]
:
(source)
¶
sqlalchemy.sql.sqltypes.Interval
, sqlalchemy.sql.sqltypes.TupleType
, sqlalchemy.sql.sqltypes.Uuid
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.sql.type_api.UserDefinedType
, sqlalchemy.sql.sqltypes._Binary
Suggest a type for a 'coerced' Python value in an expression. Given an operator and value, gives the type a chance to return a type which the value should be coerced into. The default behavior here is conservative; if the right-hand side is already coerced into a SQL type based on its Python type, it is usually left alone. End-user functionality extension here should generally be via :class:`.TypeDecorator`, which provides more liberal behavior in that it defaults to coercing the other side of the expression into this type, thus applying special Python conversions above and beyond those needed by the DBAPI to both ides. It also provides the public method :meth:`.TypeDecorator.coerce_compared_value` which is intended for end-user customization of this behavior.
Given a SELECT column expression, return a wrapping SQL expression. This is typically a SQL function that wraps a column expression as rendered in the columns clause of a SELECT statement. It is used for special data types that require columns to be wrapped in some special database function in order to coerce the value before being sent back to the application. It is the SQL analogue of the :meth:`.TypeEngine.result_processor` method. This method is called during the **SQL compilation** phase of a statement, when rendering a SQL string. It is **not** called against specific values. .. note:: This method is only called relative to a **dialect specific type object**, which is often **private to a dialect in use** and is not the same type object as the public facing one, which means it's not feasible to subclass a :class:`.types.TypeEngine` class in order to provide an alternate :meth:`_types.TypeEngine.column_expression` method, unless subclassing the :class:`_types.UserDefinedType` class explicitly. To provide alternate behavior for :meth:`_types.TypeEngine.column_expression`, implement a :class:`_types.TypeDecorator` class and provide an implementation of :meth:`_types.TypeDecorator.column_expression`. .. seealso:: :ref:`types_typedecorator` .. seealso:: :ref:`types_sql_value_processing`
Dialect
, conn_type: TypeEngine[ Any]
) -> Optional[ bool]
:
(source)
¶
Compare this type against the given backend type. This function is currently not implemented for SQLAlchemy types, and for all built in types will return ``None``. However, it can be implemented by a user-defined type where it can be consumed by schema comparison tools such as Alembic autogenerate. A future release of SQLAlchemy will potentially implement this method for builtin types as well. The function should return True if this type is equivalent to the given type; the type is typically reflected from the database so should be database specific. The dialect in use is also passed. It can also return False to assert that the type is not equivalent. :param dialect: a :class:`.Dialect` that is involved in the comparison. :param conn_type: the type object reflected from the backend. .. versionadded:: 1.0.3
Produce a string-compiled form of this :class:`.TypeEngine`. When called with no arguments, uses a "default" dialect to produce a string result. :param dialect: a :class:`.Dialect` instance.
sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.type_api.TypeDecorator
Undocumented
Return a copy of this type which has the :attr:`.should_evaluate_none` flag set to True. E.g.:: Table( 'some_table', metadata, Column( String(50).evaluates_none(), nullable=True, server_default='no value') ) The ORM uses this flag to indicate that a positive value of ``None`` is passed to the column in an INSERT statement, rather than omitting the column from the INSERT statement which has the effect of firing off column-level defaults. It also allows for types which have special behavior associated with the Python None value to indicate that the value doesn't necessarily translate into SQL NULL; a prime example of this is a JSON type which may wish to persist the JSON value ``'null'``. In all cases, the actual NULL SQL value can be always be persisted in any column by using the :obj:`_expression.null` SQL construct in an INSERT statement or associated with an ORM-mapped attribute. .. note:: The "evaluates none" flag does **not** apply to a value of ``None`` passed to :paramref:`_schema.Column.default` or :paramref:`_schema.Column.server_default`; in these cases, ``None`` still means "no default". .. versionadded:: 1.1 .. seealso:: :ref:`session_forcing_null` - in the ORM documentation :paramref:`.postgresql.JSON.none_as_null` - PostgreSQL JSON interaction with this flag. :attr:`.TypeEngine.should_evaluate_none` - class-level flag
sqlalchemy.dialects.postgresql.ENUM
, sqlalchemy.dialects.postgresql.ENUM
, sqlalchemy.sql.sqltypes.Date
, sqlalchemy.sql.sqltypes.DateTime
, sqlalchemy.sql.sqltypes.Integer
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.Time
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.dialects.mssql.pyodbc._JSON_pyodbc
, sqlalchemy.dialects.mssql.pyodbc._JSONIndexType_pyodbc
, sqlalchemy.dialects.mssql.pyodbc._JSONPathType_pyodbc
, sqlalchemy.dialects.oracle.cx_oracle._OracleInterval
, sqlalchemy.dialects.oracle.cx_oracle._OracleRowid
, sqlalchemy.dialects.oracle.types._OracleBoolean
, sqlalchemy.dialects.postgresql.pg8000._PGJSONIndexType
, sqlalchemy.sql.sqltypes._Binary
Return the corresponding type object from the underlying DB-API, if any. This can be useful for calling ``setinputsizes()``, for example.
sqlalchemy.sql.sqltypes.ARRAY
, sqlalchemy.sql.sqltypes.Boolean
, sqlalchemy.sql.sqltypes.Date
, sqlalchemy.sql.sqltypes.DateTime
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Integer
, sqlalchemy.sql.sqltypes.JSON.JSONElementType
, sqlalchemy.sql.sqltypes.NullType
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.Time
, sqlalchemy.sql.sqltypes.Uuid
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.sql.sqltypes._Binary
Return a conversion function for processing literal values that are to be rendered directly without using binds. This function is used when the compiler makes use of the "literal_binds" flag, typically used in DDL generation as well as in certain scenarios where backends don't accept bound parameters. Returns a callable which will receive a literal Python value as the sole positional argument and will return a string representation to be rendered in a SQL statement. .. note:: This method is only called relative to a **dialect specific type object**, which is often **private to a dialect in use** and is not the same type object as the public facing one, which means it's not feasible to subclass a :class:`.types.TypeEngine` class in order to provide an alternate :meth:`_types.TypeEngine.literal_processor` method, unless subclassing the :class:`_types.UserDefinedType` class explicitly. To provide alternate behavior for :meth:`_types.TypeEngine.literal_processor`, implement a :class:`_types.TypeDecorator` class and provide an implementation of :meth:`_types.TypeDecorator.process_literal_param`. .. seealso:: :ref:`types_typedecorator`
Dialect
, coltype: object
) -> Optional[ _ResultProcessorType[ _T]]
:
(source)
¶
sqlalchemy.dialects.mssql.TIME
, sqlalchemy.dialects.mysql.BIT
, sqlalchemy.dialects.mysql.TIME
, sqlalchemy.dialects.postgresql.ARRAY
, sqlalchemy.dialects.postgresql.hstore.HSTORE
, sqlalchemy.dialects.sqlite.DATE
, sqlalchemy.dialects.sqlite.DATETIME
, sqlalchemy.dialects.sqlite.TIME
, sqlalchemy.sql.sqltypes.Boolean
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Interval
, sqlalchemy.sql.sqltypes.JSON
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.TupleType
, sqlalchemy.sql.sqltypes.Uuid
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.dialects.mssql.base._MSDate
, sqlalchemy.dialects.oracle.cx_oracle._CXOracleDate
, sqlalchemy.dialects.postgresql.asyncpg._AsyncpgMultiRange
, sqlalchemy.dialects.postgresql.asyncpg._AsyncpgMultiRange
, sqlalchemy.dialects.postgresql.asyncpg._AsyncpgRange
, sqlalchemy.dialects.postgresql.psycopg._PsycopgMultiRange
, sqlalchemy.dialects.postgresql.psycopg._PsycopgMultiRange
, sqlalchemy.dialects.postgresql.psycopg._PsycopgRange
, sqlalchemy.dialects.postgresql.psycopg2._Psycopg2Range
, sqlalchemy.sql.sqltypes._Binary
Return a conversion function for processing result row values. Returns a callable which will receive a result row column value as the sole positional argument and will return a value to return to the user. If processing is not necessary, the method should return ``None``. .. note:: This method is only called relative to a **dialect specific type object**, which is often **private to a dialect in use** and is not the same type object as the public facing one, which means it's not feasible to subclass a :class:`.types.TypeEngine` class in order to provide an alternate :meth:`_types.TypeEngine.result_processor` method, unless subclassing the :class:`_types.UserDefinedType` class explicitly. To provide alternate behavior for :meth:`_types.TypeEngine.result_processor`, implement a :class:`_types.TypeDecorator` class and provide an implementation of :meth:`_types.TypeDecorator.process_result_value`. .. seealso:: :ref:`types_typedecorator` :param dialect: Dialect instance in use. :param coltype: DBAPI coltype argument received in cursor.description.
Produce a copy of this type object that will utilize the given type when applied to the dialect of the given name. e.g.:: from sqlalchemy.types import String from sqlalchemy.dialects import mysql string_type = String() string_type = string_type.with_variant( mysql.VARCHAR(collation='foo'), 'mysql', 'mariadb' ) The variant mapping indicates that when this type is interpreted by a specific dialect, it will instead be transmuted into the given type, rather than using the primary type. .. versionchanged:: 2.0 the :meth:`_types.TypeEngine.with_variant` method now works with a :class:`_types.TypeEngine` object "in place", returning a copy of the original type rather than returning a wrapping object; the ``Variant`` class is no longer used. :param type\_: a :class:`.TypeEngine` that will be selected as a variant from the originating type, when a dialect of the given name is in use. :param \*dialect_names: one or more base names of the dialect which uses this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.) .. versionchanged:: 2.0 multiple dialect names can be specified for one variant. .. seealso:: :ref:`types_with_variant` - illustrates the use of :meth:`_types.TypeEngine.with_variant`.
sqlalchemy.dialects.postgresql.hstore.HSTORE
, sqlalchemy.sql.sqltypes.ARRAY
, sqlalchemy.sql.sqltypes.JSON
Flag, if False, means values from this type aren't hashable. Used by the ORM when uniquing result lists.
sqlalchemy.dialects.postgresql.asyncpg.AsyncpgBigInteger
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgBoolean
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgCHAR
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgDate
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgDateTime
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgInteger
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgJSON
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgJSONB
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgJSONIntIndexType
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgJSONStrIndexType
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgNumeric
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgString
, sqlalchemy.dialects.postgresql.asyncpg.AsyncpgTime
, sqlalchemy.dialects.postgresql.ranges.AbstractRange
, sqlalchemy.dialects.postgresql.types.PGUuid
, sqlalchemy.dialects.postgresql._psycopg_common._PsycopgARRAY
, sqlalchemy.dialects.postgresql.pg8000._PGARRAY
, sqlalchemy.dialects.postgresql.pg8000._PGBigInteger
, sqlalchemy.dialects.postgresql.pg8000._PGBoolean
, sqlalchemy.dialects.postgresql.pg8000._PGDate
, sqlalchemy.dialects.postgresql.pg8000._PGInteger
, sqlalchemy.dialects.postgresql.pg8000._PGJSON
, sqlalchemy.dialects.postgresql.pg8000._PGJSONB
, sqlalchemy.dialects.postgresql.pg8000._PGJSONIntIndexType
, sqlalchemy.dialects.postgresql.pg8000._PGJSONStrIndexType
, sqlalchemy.dialects.postgresql.pg8000._PGNumeric
, sqlalchemy.dialects.postgresql.pg8000._PGSmallInteger
, sqlalchemy.dialects.postgresql.pg8000._PGString
, sqlalchemy.dialects.postgresql.pg8000._PGTime
, sqlalchemy.dialects.postgresql.pg8000._PGTimeStamp
, sqlalchemy.dialects.postgresql.psycopg._PGBigInteger
, sqlalchemy.dialects.postgresql.psycopg._PGBoolean
, sqlalchemy.dialects.postgresql.psycopg._PGDate
, sqlalchemy.dialects.postgresql.psycopg._PGInteger
, sqlalchemy.dialects.postgresql.psycopg._PGJSON
, sqlalchemy.dialects.postgresql.psycopg._PGJSONB
, sqlalchemy.dialects.postgresql.psycopg._PGJSONIntIndexType
, sqlalchemy.dialects.postgresql.psycopg._PGJSONStrIndexType
, sqlalchemy.dialects.postgresql.psycopg._PGNullType
, sqlalchemy.dialects.postgresql.psycopg._PGSmallInteger
, sqlalchemy.dialects.postgresql.psycopg._PGString
, sqlalchemy.dialects.postgresql.psycopg._PGTime
, sqlalchemy.dialects.postgresql.psycopg._PGTimeStamp
Render bind casts for :attr:`.BindTyping.RENDER_CASTS` mode. If True, this type (usually a dialect level impl type) signals to the compiler that a cast should be rendered around a bound parameter for this type. .. versionadded:: 2.0 .. seealso:: :class:`.BindTyping`
sqlalchemy.dialects.postgresql.types.PGUuid
render casts when rendering a value as an inline literal, e.g. with :meth:`.TypeEngine.literal_processor`. .. versionadded:: 2.0
sqlalchemy.sql.sqltypes.JSON
If True, the Python constant ``None`` is considered to be handled explicitly by this type. The ORM uses this flag to indicate that a positive value of ``None`` is passed to the column in an INSERT statement, rather than omitting the column from the INSERT statement which has the effect of firing off column-level defaults. It also allows types which have special behavior for Python None, such as a JSON type, to indicate that they'd like to handle the None value explicitly. To set this flag on an existing type, use the :meth:`.TypeEngine.evaluates_none` method. .. seealso:: :meth:`.TypeEngine.evaluates_none` .. versionadded:: 1.1
sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.type_api.TypeDecorator
A sorting function that can be passed as the key to sorted. The default value of ``None`` indicates that the values stored by this type are self-sorting. .. versionadded:: 1.3.8
sqlalchemy.dialects.postgresql.INTERVAL
, sqlalchemy.sql.sqltypes.ARRAY
, sqlalchemy.sql.sqltypes.Boolean
, sqlalchemy.sql.sqltypes.Date
, sqlalchemy.sql.sqltypes.DateTime
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Integer
, sqlalchemy.sql.sqltypes.Interval
, sqlalchemy.sql.sqltypes.Interval
, sqlalchemy.sql.sqltypes.JSON
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.Time
, sqlalchemy.sql.sqltypes.Uuid
, sqlalchemy.sql.sqltypes._Binary
Return the Python type object expected to be returned by instances of this type, if known. Basically, for those types which enforce a return type, or are known across the board to do such for all common DBAPIs (like ``int`` for example), will return that type. If a return type is not defined, raises ``NotImplementedError``. Note that any type also accommodates NULL in SQL which means you can also get back ``None`` from any type in practice.
Dialect
, key: str
, fn: Callable[ [ TypeEngine[ _T]], _O]
) -> _O
:
(source)
¶
return a dialect-specific processing object for custom purposes. The cx_Oracle dialect uses this at the moment.
Dialect
) -> Optional[ _LiteralProcessorType[ _T]]
:
(source)
¶
Return a dialect-specific literal processor for this type.
Dialect
, coltype: Any
) -> Optional[ _ResultProcessorType[ _T]]
:
(source)
¶
Return a dialect-specific result processor for this type.
Return a dialect-specific registry which caches a dialect-specific implementation, bind processing function, and one or more result processing functions.
sqlalchemy.dialects.postgresql.ranges.AbstractRange
, sqlalchemy.sql.sqltypes.DateTime
, sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Integer
, sqlalchemy.sql.sqltypes.String
, sqlalchemy.sql.sqltypes.Time
adjust this type given a literal Python value that will be stored in a bound parameter. Used exclusively by _resolve_value_to_type(). .. versionadded:: 1.4.30 or 2.0 TODO: this should be part of public API .. seealso:: :meth:`.TypeEngine._resolve_for_python_type`
Type[ Any]
, matched_on: _MatchedOnType
, matched_on_flattened: Type[ Any]
) -> Optional[ Self]
:
(source)
¶
sqlalchemy.sql.sqltypes.Enum
, sqlalchemy.sql.sqltypes.Enum
given a Python type (e.g. ``int``, ``str``, etc. ) return an instance of this :class:`.TypeEngine` that's appropriate for this type. An additional argument ``matched_on`` is passed, which indicates an entry from the ``__mro__`` of the given ``python_type`` that more specifically matches how the caller located this :class:`.TypeEngine` object. Such as, if a lookup of some kind links the ``int`` Python type to the :class:`.Integer` SQL type, and the original object was some custom subclass of ``int`` such as ``MyInt(int)``, the arguments passed would be ``(MyInt, int)``. If the given Python type does not correspond to this :class:`.TypeEngine`, or the Python type is otherwise ambiguous, the method should return None. For simple cases, the method checks that the ``python_type`` and ``matched_on`` types are the same (i.e. not a subclass), and returns self; for all other cases, it returns ``None``. The initial use case here is for the ORM to link user-defined Python standard library ``enum.Enum`` classes to the SQLAlchemy :class:`.Enum` SQL type when constructing ORM Declarative mappings. :param python_type: the Python type we want to use :param matched_on: the Python type that led us to choose this particular :class:`.TypeEngine` class, which would be a supertype of ``python_type``. By default, the request is rejected if ``python_type`` doesn't match ``matched_on`` (None is returned). .. versionadded:: 2.0.0b4 TODO: this should be part of public API .. seealso:: :meth:`.TypeEngine._resolve_for_literal`
sqlalchemy.sql.type_api.TypeDecorator
Return the 'unwrapped' dialect impl for this type. For a type that applies wrapping logic (e.g. TypeDecorator), give us the real, actual dialect-level type that is used. This is used by TypeDecorator itself as well at least one case where dialects need to check that a particular specific dialect-level type is in use, within the :meth:`.DefaultDialect.set_input_sizes` method.
sqlalchemy.sql.type_api.TypeDecorator
memoized boolean, check if bind_expression is implemented. Allows the method to be skipped for the vast majority of expression types that don't use this feature.
sqlalchemy.sql.type_api.TypeDecorator
memoized boolean, check if column_expression is implemented. Allows the method to be skipped for the vast majority of expression types that don't use this feature.
sqlalchemy.sql.sqltypes.Integer
, sqlalchemy.sql.sqltypes.Numeric
, sqlalchemy.sql.type_api.TypeDecorator
, sqlalchemy.sql.sqltypes._AbstractInterval
Return a rudimental 'affinity' value expressing the general class of type.