Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé
Module « sqlalchemy.orm »

Fonction synonym_for - module sqlalchemy.orm

Signature de la fonction synonym_for

def synonym_for(name: 'str', map_column: 'bool' = False) -> 'Callable[[Callable[..., Any]], Synonym[Any]]' 

Description

help(sqlalchemy.orm.synonym_for)

Decorator that produces an :func:`_orm.synonym`
attribute in conjunction with a Python descriptor.

The function being decorated is passed to :func:`_orm.synonym` as the
:paramref:`.orm.synonym.descriptor` parameter::

    class MyClass(Base):
        __tablename__ = "my_table"

        id = Column(Integer, primary_key=True)
        _job_status = Column("job_status", String(50))

        @synonym_for("job_status")
        @property
        def job_status(self):
            return "Status: %s" % self._job_status

The :ref:`hybrid properties <mapper_hybrids>` feature of SQLAlchemy
is typically preferred instead of synonyms, which is a more legacy
feature.

.. seealso::

    :ref:`synonyms` - Overview of synonyms

    :func:`_orm.synonym` - the mapper-level function

    :ref:`mapper_hybrids` - The Hybrid Attribute extension provides an
    updated approach to augmenting attribute behavior more flexibly than
    can be achieved with synonyms.



Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé