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 :

Module « sqlalchemy »

Classe « Numeric »

Informations générales

Héritage

builtins.object
    Traversible
        TypeEngine
    builtins.object
        _LookupExpressionAdapter
            Numeric

Définition

class Numeric(_LookupExpressionAdapter, TypeEngine):

Description [extrait de Numeric.__doc__]

A type for fixed precision numbers, such as ``NUMERIC`` or ``DECIMAL``.

    This type returns Python ``decimal.Decimal`` objects by default, unless
    the :paramref:`.Numeric.asdecimal` flag is set to False, in which case
    they are coerced to Python ``float`` objects.

    .. note::

        The :class:`.Numeric` type is designed to receive data from a database
        type that is explicitly known to be a decimal type
        (e.g. ``DECIMAL``, ``NUMERIC``, others) and not a floating point
        type (e.g. ``FLOAT``, ``REAL``, others).
        If the database column on the server is in fact a floating-point
        type, such as ``FLOAT`` or ``REAL``, use the :class:`.Float`
        type or a subclass, otherwise numeric coercion between
        ``float``/``Decimal`` may or may not function as expected.

    .. note::

       The Python ``decimal.Decimal`` class is generally slow
       performing; cPython 3.3 has now switched to use the `cdecimal
       <https://pypi.org/project/cdecimal/>`_ library natively. For
       older Python versions, the ``cdecimal`` library can be patched
       into any application where it will replace the ``decimal``
       library fully, however this needs to be applied globally and
       before any other modules have been imported, as follows::

           import sys
           import cdecimal
           sys.modules["decimal"] = cdecimal

       Note that the ``cdecimal`` and ``decimal`` libraries are **not
       compatible with each other**, so patching ``cdecimal`` at the
       global level is the only way it can be used effectively with
       various DBAPIs that hardcode to import the ``decimal`` library.

    

Constructeur(s)

Signature du constructeur Description
__init__(self, precision=None, scale=None, decimal_return_scale=None, asdecimal=True)

Liste des attributs statiques

Nom de l'attribut Valeur
hashableTrue
should_evaluate_noneFalse
sort_key_functionNone

Liste des propriétés

Nom de la propriétéDescription
python_type

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
bind_processor(self, dialect)
get_dbapi_type(self, dbapi)
literal_processor(self, dialect)
result_processor(self, dialect, coltype)

Méthodes héritées de la classe TypeEngine

__init_subclass__, __repr__, __str__, __subclasshook__, adapt, as_generic, bind_expression, coerce_compared_value, column_expression, Comparator, comparator_factory, compare_against_backend, compare_values, compile, copy, copy_value, dialect_impl, evaluates_none, with_variant

Méthodes héritées de la classe Traversible

__class_getitem__, get_children

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__