当前位置: 首页>>代码示例>>Python>>正文


Python compat.string_types方法代码示例

本文整理汇总了Python中sqlalchemy.util.compat.string_types方法的典型用法代码示例。如果您正苦于以下问题:Python compat.string_types方法的具体用法?Python compat.string_types怎么用?Python compat.string_types使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.util.compat的用法示例。


在下文中一共展示了compat.string_types方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: result_processor

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def result_processor(self, dialect, coltype):
        if not dialect.auto_convert_lobs:
            # Disable processor and return raw DBAPI LOB type
            return None

        def process(value):
            if value is None:
                return None
            if isinstance(value, compat.string_types):
                return value
            if isinstance(value, memoryview):
                return value.obj
            if compat.py2k and isinstance(value, buffer):
                return value
            if hasattr(value, "read"):
                return value.read()
            raise NotImplementedError
        return process 
开发者ID:SAP,项目名称:sqlalchemy-hana,代码行数:20,代码来源:types.py

示例2: visit_aws_bucket

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def visit_aws_bucket(self, aws_bucket, **kw):
        credentials_list = list(aws_bucket.credentials_used.items())
        if kw.get('deterministic', False):
            credentials_list.sort(key=operator.itemgetter(0))
        credentials = 'CREDENTIALS=({})'.format(
            ' '.join("{}='{}'".format(n, v) for n, v in credentials_list)
        )
        encryption_list = list(aws_bucket.encryption_used.items())
        if kw.get('deterministic', False):
            encryption_list.sort(key=operator.itemgetter(0))
        encryption = 'ENCRYPTION=({})'.format(
            ' '.join(("{}='{}'" if isinstance(v, string_types) else "{}={}").format(n, v) for n, v in encryption_list)
        )
        uri = "'s3://{}{}'".format(aws_bucket.bucket, '/' + aws_bucket.path if aws_bucket.path else "")
        return (uri,
                credentials if aws_bucket.credentials_used else '',
                encryption if aws_bucket.encryption_used else '') 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:19,代码来源:base.py

示例3: visit_azure_container

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def visit_azure_container(self, azure_container, **kw):
        credentials_list = list(azure_container.credentials_used.items())
        if kw.get('deterministic', False):
            credentials_list.sort(key=operator.itemgetter(0))
        credentials = 'CREDENTIALS=({})'.format(' '.join("{}='{}'".format(n, v) for n, v in credentials_list))
        encryption_list = list(azure_container.encryption_used.items())
        if kw.get('deterministic', False):
            encryption_list.sort(key=operator.itemgetter(0))
        encryption = 'ENCRYPTION=({})'.format(
            ' '.join(("{}='{}'" if isinstance(v, string_types) else "{}={}").format(n, v) for n, v in
                     encryption_list)
        )
        uri = "'azure://{}.blob.core.windows.net/{}{}'".format(
            azure_container.account,
            azure_container.container,
            '/' + azure_container.path if azure_container.path else ""
        )
        return (uri,
                credentials if azure_container.credentials_used else '',
                encryption if azure_container.encryption_used else '') 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:22,代码来源:base.py

示例4: __call__

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def __call__(self, cfg, *arg):
        if isinstance(cfg, compat.string_types):
            url = sa_url.make_url(cfg)
        elif isinstance(cfg, sa_url.URL):
            url = cfg
        else:
            url = cfg.db.url
        backend = url.get_backend_name()
        if backend in self.fns:
            return self.fns[backend](cfg, *arg)
        else:
            return self.fns['*'](cfg, *arg) 
开发者ID:jpush,项目名称:jbox,代码行数:14,代码来源:provision.py

示例5: compression

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def compression(self, comp_type):
        """String (constant) that specifies to compresses the unloaded data files using the specified compression algorithm."""
        if isinstance(comp_type, string_types):
            comp_type = comp_type.lower()
        _available_options = ['auto', 'gzip', 'bz2', 'brotli', 'zstd', 'deflate', 'raw_deflate', None]
        if comp_type not in _available_options:
            raise TypeError("Compression type should be one of : {}".format(_available_options))
        self.options['COMPRESSION'] = comp_type
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:11,代码来源:custom_commands.py

示例6: record_delimiter

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def record_delimiter(self, deli_type):
        """Character that separates records in an unloaded file."""
        if not isinstance(deli_type, (int, string_types)) \
                or (isinstance(deli_type, string_types) and len(deli_type) != 1):
            raise TypeError("Record delimeter should be a single character, that is either a string, or a number")
        if isinstance(deli_type, int):
            self.options['RECORD_DELIMITER'] = hex(deli_type)
        else:
            self.options['RECORD_DELIMITER'] = deli_type
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:12,代码来源:custom_commands.py

示例7: field_delimiter

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def field_delimiter(self, deli_type):
        """Character that separates fields in an unloaded file."""
        if not isinstance(deli_type, (int, NoneType, string_types)) \
                or (isinstance(deli_type, string_types) and len(deli_type) != 1):
            raise TypeError("Field delimeter should be a single character, that is either a string, or a number")
        if isinstance(deli_type, int):
            self.options['FIELD_DELIMITER'] = hex(deli_type)
        else:
            self.options['FIELD_DELIMITER'] = deli_type
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:12,代码来源:custom_commands.py

示例8: date_format

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def date_format(self, dt_frmt):
        """String that defines the format of date values in the unloaded data files."""
        if not isinstance(dt_frmt, string_types):
            raise TypeError("Date format should be a string")
        self.options['DATE_FORMAT'] = dt_frmt
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:8,代码来源:custom_commands.py

示例9: time_format

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def time_format(self, tm_frmt):
        """String that defines the format of time values in the unloaded data files."""
        if not isinstance(tm_frmt, string_types):
            raise TypeError("Time format should be a string")
        self.options['TIME_FORMAT'] = tm_frmt
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:8,代码来源:custom_commands.py

示例10: timestamp_format

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def timestamp_format(self, tmstmp_frmt):
        """String that defines the format of timestamp values in the unloaded data files."""
        if not isinstance(tmstmp_frmt, string_types):
            raise TypeError("Timestamp format should be a string")
        self.options['TIMESTAMP_FORMAT'] = tmstmp_frmt
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:8,代码来源:custom_commands.py

示例11: binary_format

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def binary_format(self, bin_fmt):
        """Character used as the escape character for any field values. The option can be used when unloading data
        from binary columns in a table. """
        if isinstance(bin_fmt, string_types):
            bin_fmt = bin_fmt.lower()
        _available_options = ['hex', 'base64', 'utf8']
        if bin_fmt not in _available_options:
            raise TypeError("Binary format should be one of : {}".format(_available_options))
        self.options['BINARY_FORMAT'] = bin_fmt
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:12,代码来源:custom_commands.py

示例12: escape

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def escape(self, esc):
        """Character used as the escape character for any field values."""
        if not isinstance(esc, (int, NoneType, string_types)) \
                or (isinstance(esc, string_types) and len(esc) != 1):
            raise TypeError("Escape should be a single character, that is either a string, or a number")
        if isinstance(esc, int):
            self.options['ESCAPE'] = hex(esc)
        else:
            self.options['ESCAPE'] = esc
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:12,代码来源:custom_commands.py

示例13: file_extension

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def file_extension(self, ext):
        """String that specifies the extension for files unloaded to a stage. Accepts any extension. The user is
        responsible for specifying a valid file extension that can be read by the desired software or service. """
        if not isinstance(ext, (NoneType, string_types)):
            raise TypeError("File extension should be a string")
        self.options['FILE_EXTENSION'] = ext
        return self 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:9,代码来源:custom_commands.py

示例14: __repr__

# 需要导入模块: from sqlalchemy.util import compat [as 别名]
# 或者: from sqlalchemy.util.compat import string_types [as 别名]
def __repr__(self):
        credentials = 'CREDENTIALS=({})'.format(
            ' '.join("{}='{}'".format(n, v) for n, v in self.credentials_used.items())
        )
        encryption = 'ENCRYPTION=({})'.format(
            ' '.join(("{}='{}'" if isinstance(v, string_types) else "{}={}").format(n, v)
                     for n, v in self.encryption_used.items())
        )
        uri = "'s3://{}{}'".format(self.bucket, '/' + self.path if self.path else "")
        return '{}{}{}'.format(uri,
                               ' ' + credentials if self.credentials_used else '',
                               ' ' + encryption if self.encryption_used else '') 
开发者ID:snowflakedb,项目名称:snowflake-sqlalchemy,代码行数:14,代码来源:custom_commands.py


注:本文中的sqlalchemy.util.compat.string_types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。