本文整理汇总了Python中sqlalchemy.types.REAL属性的典型用法代码示例。如果您正苦于以下问题:Python types.REAL属性的具体用法?Python types.REAL怎么用?Python types.REAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sqlalchemy.types
的用法示例。
在下文中一共展示了types.REAL属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _type_affinity_fixture
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import REAL [as 别名]
def _type_affinity_fixture(self):
return [
("LONGTEXT", sqltypes.TEXT()),
("TINYINT", sqltypes.INTEGER()),
("MEDIUMINT", sqltypes.INTEGER()),
("INT2", sqltypes.INTEGER()),
("UNSIGNED BIG INT", sqltypes.INTEGER()),
("INT8", sqltypes.INTEGER()),
("CHARACTER(20)", sqltypes.TEXT()),
("CLOB", sqltypes.TEXT()),
("CLOBBER", sqltypes.TEXT()),
("VARYING CHARACTER(70)", sqltypes.TEXT()),
("NATIVE CHARACTER(70)", sqltypes.TEXT()),
("BLOB", sqltypes.BLOB()),
("BLOBBER", sqltypes.NullType()),
("DOUBLE PRECISION", sqltypes.REAL()),
("FLOATY", sqltypes.REAL()),
("SOMETHING UNKNOWN", sqltypes.NUMERIC()),
]
示例2: sqltype_to_stdtype
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import REAL [as 别名]
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
示例3: __init__
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import REAL [as 别名]
def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
if isinstance(self, (REAL, DOUBLE)) and \
(
(precision is None and scale is not None) or
(precision is not None and scale is None)
):
raise exc.ArgumentError(
"You must specify both precision and scale or omit "
"both altogether.")
super(_FloatType, self).__init__(precision=precision,
asdecimal=asdecimal, **kw)
self.scale = scale
示例4: migrate_table
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import REAL [as 别名]
def migrate_table(db, logger):
old_table = Table(
'quote',
database.metadata,
Column('chan', String(25)),
Column('nick', String(25)),
Column('add_nick', String(25)),
Column('msg', String(500)),
Column('time', REAL),
Column('deleted', String(5), default=0),
PrimaryKeyConstraint('chan', 'nick', 'time')
)
if not old_table.exists():
database.metadata.remove(old_table)
return
old_quotes = db.execute(old_table.select()).fetchall()
if not old_quotes:
return
logger.info("Migrating quotes table")
qtable.drop(checkfirst=True)
qtable.create(checkfirst=True)
db.execute(qtable.insert().values([
{
'chan': row['chan'],
'nick': row['nick'],
'add_nick': row['add_nick'],
'msg': row['msg'],
'time': row['time'],
'deleted': row['deleted'] in (1, '1', True)
} for row in old_quotes
]))
logger.info("Migrated all quotes")
db.commit()
old_table.drop()
database.metadata.remove(old_table)