Python sqlalchemy.FLOAT Examples
The following are 7
code examples of sqlalchemy.FLOAT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy
, or try the search function
.
Example #1
Source File: test_compiler.py From sqlalchemy with MIT License | 6 votes |
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)", )
Example #2
Source File: 1733c4d4c77b_.py From SempoBlockchain with GNU General Public License v3.0 | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('exchange', sa.Column('exchange_rate', sa.FLOAT(), nullable=True)) # ### end Alembic commands ###
Example #3
Source File: test_reflection.py From sqlalchemy with MIT License | 5 votes |
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"])
Example #4
Source File: test_compiler.py From sqlalchemy with MIT License | 5 votes |
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)" )
Example #5
Source File: test_types.py From sqlalchemy with MIT License | 5 votes |
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_)
Example #6
Source File: test_types.py From sqlalchemy with MIT License | 5 votes |
def test_default_compile_pg_float(self): self.assert_compile( dialects.postgresql.FLOAT(), "FLOAT", allow_dialect_select=True )
Example #7
Source File: test_types.py From sqlalchemy with MIT License | 4 votes |
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_, )