本文整理汇总了Python中sqlalchemy.types.Binary方法的典型用法代码示例。如果您正苦于以下问题:Python types.Binary方法的具体用法?Python types.Binary怎么用?Python types.Binary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.types
的用法示例。
在下文中一共展示了types.Binary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fields_map
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Binary [as 别名]
def fields_map(self, field_type):
if field_type == "primary":
return {'type': 'keyword'}
type_map = {
'date': types.Date,
'datetime': types.DateTime,
'boolean': types.Boolean,
'integer': types.Integer,
'float': types.Float,
'binary': types.Binary
}
if isinstance(field_type, str):
field_type = type_map.get(field_type, types.Text)
if not isinstance(field_type, type):
field_type = field_type.__class__
if issubclass(field_type, (types.DateTime, types.Date)):
return {'type': 'date'}
elif issubclass(field_type, types.Integer):
return {'type': 'long'}
elif issubclass(field_type, types.Float):
return {'type': 'float'}
elif issubclass(field_type, types.Boolean):
return {'type': 'boolean'}
elif issubclass(field_type, types.Binary):
return {'type': 'binary'}
return {'type': 'string'}
# https://medium.com/@federicopanini/elasticsearch-6-0-removal-of-mapping-types-526a67ff772
示例2: test_should_unknown_sqlalchemy_field_raise_exception
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Binary [as 别名]
def test_should_unknown_sqlalchemy_field_raise_exception():
re_err = "Don't know how to convert the SQLAlchemy field"
with pytest.raises(Exception, match=re_err):
# support legacy Binary type and subsequent LargeBinary
get_field(getattr(types, 'LargeBinary', types.Binary)())
示例3: upgrade
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Binary [as 别名]
def upgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
base_transfer_action = sqlalchemy.Table(
'base_transfer_action', meta, autoload=True)
base_transfer_action.c.info.alter(type=types.Binary(4294967295))