当前位置: 首页>>代码示例>>Python>>正文


Python sqlalchemy.FLOAT属性代码示例

本文整理汇总了Python中sqlalchemy.FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.FLOAT属性的具体用法?Python sqlalchemy.FLOAT怎么用?Python sqlalchemy.FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sqlalchemy的用法示例。


在下文中一共展示了sqlalchemy.FLOAT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unsupported_cast_literal_bind

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def test_unsupported_cast_literal_bind(self):
        expr = cast(column("foo", Integer) + 5, Float)

        with expect_warnings("Datatype FLOAT does not support CAST on MySQL;"):
            self.assert_compile(expr, "(foo + 5)", literal_binds=True)

        dialect = mysql.MySQLDialect()
        dialect.server_version_info = (3, 9, 8)
        with expect_warnings("Current MySQL version does not support CAST"):
            eq_(
                str(
                    expr.compile(
                        dialect=dialect, compile_kwargs={"literal_binds": True}
                    )
                ),
                "(foo + 5)",
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_compiler.py

示例2: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('exchange', sa.Column('exchange_rate', sa.FLOAT(), nullable=True))
    # ### end Alembic commands ### 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:6,代码来源:1733c4d4c77b_.py

示例3: test_float_types

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def test_float_types(self):
        specs = [
            (DOUBLE_PRECISION(), FLOAT()),
            # when binary_precision is supported
            # (DOUBLE_PRECISION(), oracle.FLOAT(binary_precision=126)),
            (BINARY_DOUBLE(), BINARY_DOUBLE()),
            (BINARY_FLOAT(), BINARY_FLOAT()),
            (FLOAT(5), FLOAT()),
            # when binary_precision is supported
            # (FLOAT(5), oracle.FLOAT(binary_precision=5),),
            (FLOAT(), FLOAT()),
            # when binary_precision is supported
            # (FLOAT(5), oracle.FLOAT(binary_precision=126),),
        ]
        self._run_test(specs, ["precision"]) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:test_reflection.py

示例4: test_cast_grouped_expression_non_castable

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def test_cast_grouped_expression_non_castable(self):
        with expect_warnings("Datatype FLOAT does not support CAST on MySQL;"):
            self.assert_compile(
                cast(sql.column("x") + sql.column("y"), Float), "(x + y)"
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:7,代码来源:test_compiler.py

示例5: test_typedecorator_impl

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def test_typedecorator_impl(self):
        for impl_, exp, kw in [
            (Float, "FLOAT", {}),
            (Float, "FLOAT(2)", {"precision": 2}),
            (Float(2), "FLOAT(2)", {"precision": 4}),
            (Numeric(19, 2), "NUMERIC(19, 2)", {}),
        ]:
            for dialect_ in (
                dialects.postgresql,
                dialects.mssql,
                dialects.mysql,
            ):
                dialect_ = dialect_.dialect()

                raw_impl = types.to_instance(impl_, **kw)

                class MyType(types.TypeDecorator):
                    impl = impl_

                dec_type = MyType(**kw)

                eq_(dec_type.impl.__class__, raw_impl.__class__)

                raw_dialect_impl = raw_impl.dialect_impl(dialect_)
                dec_dialect_impl = dec_type.dialect_impl(dialect_)
                eq_(dec_dialect_impl.__class__, MyType)
                eq_(
                    raw_dialect_impl.__class__, dec_dialect_impl.impl.__class__
                )

                self.assert_compile(MyType(**kw), exp, dialect=dialect_) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:33,代码来源:test_types.py

示例6: test_default_compile_pg_float

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def test_default_compile_pg_float(self):
        self.assert_compile(
            dialects.postgresql.FLOAT(), "FLOAT", allow_dialect_select=True
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:6,代码来源:test_types.py

示例7: test_numerics

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import FLOAT [as 别名]
def test_numerics(self):
        m = self.metadata
        t1 = Table(
            "t1",
            m,
            Column("intcol", Integer),
            Column("numericcol", Numeric(precision=9, scale=2)),
            Column("floatcol1", Float()),
            Column("floatcol2", FLOAT()),
            Column("doubleprec", oracle.DOUBLE_PRECISION),
            Column("numbercol1", oracle.NUMBER(9)),
            Column("numbercol2", oracle.NUMBER(9, 3)),
            Column("numbercol3", oracle.NUMBER),
        )
        t1.create()
        t1.insert().execute(
            intcol=1,
            numericcol=5.2,
            floatcol1=6.5,
            floatcol2=8.5,
            doubleprec=9.5,
            numbercol1=12,
            numbercol2=14.85,
            numbercol3=15.76,
        )

        m2 = MetaData(testing.db)
        t2 = Table("t1", m2, autoload=True)

        for row in (
            t1.select().execute().first(),
            t2.select().execute().first(),
        ):
            for i, (val, type_) in enumerate(
                (
                    (1, int),
                    (decimal.Decimal("5.2"), decimal.Decimal),
                    (6.5, float),
                    (8.5, float),
                    (9.5, float),
                    (12, int),
                    (decimal.Decimal("14.85"), decimal.Decimal),
                    (15.76, float),
                )
            ):
                eq_(row[i], val)
                assert isinstance(row[i], type_), "%r is not %r" % (
                    row[i],
                    type_,
                ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:52,代码来源:test_types.py


注:本文中的sqlalchemy.FLOAT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。