Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)
Function that assigns automatic data type coercion for all classes which
are of type of given mapper. The coercion is applied to all coercion
capable properties. By default coercion is applied to all SQLAlchemy
mappers.

Before initializing your models you need to call force_auto_coercion.

::

    from sqlalchemy_utils import force_auto_coercion(more...)

        def force_auto_coercion(mapper=None):
    """
    Function that assigns automatic data type coercion for all classes which
    are of type of given mapper. The coercion is applied to all coercion
    capable properties. By default coercion is applied to all SQLAlchemy
    mappers.

    Before initializing your models you need to call force_auto_coercion.

    ::

        from sqlalchemy_utils import force_auto_coercion


        force_auto_coercion()


    Then define your models the usual way::


        class Document(Base):
            __tablename__ = 'document'
            id = sa.Column(sa.Integer, autoincrement=True)
            name = sa.Column(sa.Unicode(50))
            background_color = sa.Column(ColorType)


    Now scalar values for coercion capable data types will convert to
    appropriate value objects::

        document = Document()
        document.background_color = 'F5F5F5'
        document.background_color  # Color object
        session.commit()


    :param mapper: The mapper which the automatic data type coercion should be
                   applied to
    """
    if mapper is None:
        mapper = sa.orm.mapper
    sa.event.listen(mapper, 'mapper_configured', coercion_listener)
        


src/s/q/SQLAlchemy-Utils-0.25.4/sqlalchemy_utils/__init__.py   SQLAlchemy-Utils(Download)
    table_name,
)
from .listeners import (
    coercion_listener,
    force_auto_coercion,

src/s/q/sqlalchemy-utils-HEAD/sqlalchemy_utils/__init__.py   sqlalchemy-utils(Download)
    table_name,
)
from .listeners import (
    coercion_listener,
    force_auto_coercion,