本文整理汇总了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)",
)
示例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 ###
示例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"])
示例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)"
)
示例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_)
示例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
)
示例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_,
)