Here are the examples of the python api sqlalchemy.FLOAT taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
3
Source : test_reflection.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
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"])
3
Source : test_types.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_no_decimal_float_precision(self):
with expect_raises_message(
exc.ArgumentError,
"Oracle FLOAT types use 'binary precision', which does not "
"convert cleanly from decimal 'precision'. Please specify this "
"type with a separate Oracle variant, such as "
r"FLOAT\(precision=5\).with_variant\(oracle.FLOAT\("
r"binary_precision=16\), 'oracle'\), so that the Oracle "
"specific 'binary_precision' may be specified accurately.",
):
FLOAT(5).compile(dialect=oracle.dialect())
def test_numerics(self, metadata, connection):
3
Source : 1733c4d4c77b_.py
with GNU General Public License v3.0
from teamsempo
with GNU General Public License v3.0
from teamsempo
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('exchange', sa.Column('exchange_rate', sa.FLOAT(), nullable=True))
# ### end Alembic commands ###
def downgrade():
3
Source : f78c5b7d4a52_add_osm_solar_node_table.py
with GNU General Public License v3.0
from typicalTYLER
with GNU General Public License v3.0
from typicalTYLER
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('solar_nodes',
sa.Column('longitude', sa.FLOAT(), nullable=False),
sa.Column('latitude', sa.FLOAT(), nullable=False),
sa.PrimaryKeyConstraint('longitude', 'latitude', sqlite_on_conflict='IGNORE')
)
# ### end Alembic commands ###
0
Source : test_types.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
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_,
)
@testing.provide_metadata
0
Source : test_reflection.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_float_types(
self,
metadata,
connection,
):
specs = [
(DOUBLE_PRECISION(), DOUBLE_PRECISION()),
(Double(), DOUBLE_PRECISION()),
(REAL(), REAL()),
(BINARY_DOUBLE(), BINARY_DOUBLE()),
(BINARY_FLOAT(), BINARY_FLOAT()),
(oracle.FLOAT(5), oracle.FLOAT(5)),
(
Float(5).with_variant(
oracle.FLOAT(binary_precision=16), "oracle"
),
oracle.FLOAT(16),
), # using conversion
(FLOAT(), DOUBLE_PRECISION()),
# from https://docs.oracle.com/cd/B14117_01/server.101/b10758/sqlqr06.htm # noqa E501
# DOUBLE PRECISION == precision 126
# REAL == precision 63
(oracle.FLOAT(126), DOUBLE_PRECISION()),
(oracle.FLOAT(63), REAL()),
]
self._run_test(metadata, connection, specs, ["precision"])
class IdentityReflectionTest(fixtures.TablesTest):
0
Source : test_types.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_numerics(self, metadata, connection):
m = metadata
t1 = Table(
"t1",
m,
Column("intcol", Integer),
Column("numericcol", Numeric(precision=9, scale=2)),
Column("floatcol1", Float()),
Column("floatcol2", FLOAT()),
Column("doubleprec1", DOUBLE_PRECISION),
Column("doubleprec2", Double()),
Column("numbercol1", oracle.NUMBER(9)),
Column("numbercol2", oracle.NUMBER(9, 3)),
Column("numbercol3", oracle.NUMBER),
)
t1.create(connection)
connection.execute(
t1.insert(),
dict(
intcol=1,
numericcol=5.2,
floatcol1=6.5,
floatcol2=8.5,
doubleprec1=9.5,
doubleprec2=14.5,
numbercol1=12,
numbercol2=14.85,
numbercol3=15.76,
),
)
m2 = MetaData()
t2 = Table("t1", m2, autoload_with=connection)
for row in (
connection.execute(t1.select()).first(),
connection.execute(t2.select()).first(),
):
for i, (val, type_) in enumerate(
(
(1, int),
(decimal.Decimal("5.2"), decimal.Decimal),
(6.5, float),
(8.5, float),
(9.5, float),
(14.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_,
)
def test_numeric_infinity_float(self, metadata, connection):