Python sqlalchemy.types 模块,NUMERIC 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用sqlalchemy.types.NUMERIC

项目:sqlacodegen    作者:agronholm    | 项目源码 | 文件源码
def test_fancy_coltypes(self):
        Table(
            'simple_items', self.metadata,
            Column('enum', ENUM('A', 'B', name='blah')),
            Column('bool', BOOLEAN),
            Column('number', NUMERIC(10, asdecimal=False)),
        )

        assert self.generate_code() == """\
# coding: utf-8
from sqlalchemy import Boolean, Column, Enum, MetaData, Numeric, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('enum', Enum('A', 'B', name='blah')),
    Column('bool', Boolean),
    Column('number', Numeric(10, asdecimal=False))
)
"""
项目:panko    作者:openstack    | 项目源码 | 文件源码
def fake_dialect(name):
        def _type_descriptor_mock(desc):
            if type(desc) == DECIMAL:
                return NUMERIC(precision=desc.precision, scale=desc.scale)
        dialect = mock.MagicMock()
        dialect.name = name
        dialect.type_descriptor = _type_descriptor_mock
        return dialect
项目:panko    作者:openstack    | 项目源码 | 文件源码
def test_load_dialect_impl_mysql(self):
        result = self._type.load_dialect_impl(self._mysql_dialect)
        self.assertEqual(NUMERIC, type(result))
        self.assertEqual(20, result.precision)
        self.assertEqual(6, result.scale)
        self.assertTrue(result.asdecimal)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
        """Construct a NUMERIC.

        :param precision: Total digits in this number.  If scale and precision
          are both None, values are stored to limits allowed by the server.

        :param scale: The number of digits after the decimal point.

        """

        super(NUMERIC, self).__init__(precision=precision, scale=scale,
                                      asdecimal=asdecimal, **kw)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
        """Construct a NUMERIC.

        :param precision: Total digits in this number.  If scale and precision
          are both None, values are stored to limits allowed by the server.

        :param scale: The number of digits after the decimal point.

        """

        super(NUMERIC, self).__init__(precision=precision, scale=scale,
                                      asdecimal=asdecimal, **kw)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
        """Construct a NUMERIC.

        :param precision: Total digits in this number.  If scale and precision
          are both None, values are stored to limits allowed by the server.

        :param scale: The number of digits after the decimal point.

        """

        super(NUMERIC, self).__init__(precision=precision, scale=scale,
                                      asdecimal=asdecimal, **kw)
项目:parade    作者:bailaohe    | 项目源码 | 文件源码
def sqltype_to_stdtype(sqltype):
    import sqlalchemy.types as sqltypes
    if isinstance(sqltype, (sqltypes.VARCHAR, sqltypes.CHAR, sqltypes.TEXT, sqltypes.Enum, sqltypes.String)):
        return _STRING_TYPE
    if isinstance(sqltype, (sqltypes.DATETIME, sqltypes.DATE, sqltypes.TIME, sqltypes.TIMESTAMP)):
        return _DATE_TYPE
    if isinstance(sqltype, (sqltypes.INTEGER, sqltypes.BIGINT, sqltypes.SMALLINT, sqltypes.Integer)):
        return _INTEGER_TYPE
    if isinstance(sqltype, (sqltypes.REAL, sqltypes.DECIMAL, sqltypes.NUMERIC, sqltypes.FLOAT)):
        return _DECIMAL_TYPE
    if isinstance(sqltype, sqltypes.BOOLEAN):
        return _BOOLEAN_TYPE