當前位置: 首頁>>代碼示例>>Python>>正文


Python types.Binary方法代碼示例

本文整理匯總了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 
開發者ID:honmaple,項目名稱:flask-msearch,代碼行數:34,代碼來源:elasticsearch_backend.py

示例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)()) 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:7,代碼來源:test_converter.py

示例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)) 
開發者ID:cloudbase,項目名稱:coriolis,代碼行數:10,代碼來源:009_Migrate_info_to_blob.py


注:本文中的sqlalchemy.types.Binary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。