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


Python BaseHub.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import __init__ [as 别名]
    def __init__(self, data_source_name):
        """
        A derived class of BaseHub, serves as a base class for any Relational
        Database hubs.
        """
        BaseHub.__init__(self)

        # allowed keys in execute
        self.execute_keys = set(['db',
                                 'proc',
                                 'nocommit',
                                 'sql',
                                 'host_type',
                                 'placeholders',
                                 'replace',
                                 'replace_quote',
                                 'limit',
                                 'offset',
                                 'chunk_size',
                                 'chunk_source',
                                 'chunk_min',
                                 'chunk_total',
                                 'executemany',
                                 'return_type',
                                 'key_column',
                                 'callback',
                                 'debug_show',
                                 'debug_noex'])

        # Default values for execute kwargs
        self.default_host_type = 'master_host'
        self.default_return_type = 'tuple'

        # replace string base for replace functionality in execute
        self.replace_string = 'REP'

        # set of return types that require a key_column
        self.return_type_key_columns = set(['dict', 'dict_json', 'set', 'set_json'])

        # One of these keys must be provided to execute
        self.execute_required_keys = set(['proc', 'sql'])

        # This data structure is used to map the return_type provided to
        # execute() to the derived hub method.  Derived hub's have to map
        # their methods by setting the appropriate function reference to
        # its associated key in valid_return_types.
        self.valid_return_types = {'iter': None,
                                   'dict': None,
                                   'dict_json': None,
                                   'tuple': None,
                                   'tuple_json': None,
                                   'set': None,
                                   'set_json': None,
                                   'table': None,
                                   'table_json': None,
                                   'rowcount': None,
                                   'callback': None}

        # Dictionary of required keys for RDBS datasources
        self.data_source_req_keys = dict(
            # required keys
            req=set(['hub', 'master_host']),
            # optional keys but if present have additional key requirements
            databases=set(['name', 'procs']),
            master_host=set(['host', 'user']),
            read_host=set(['host', 'user']),
            dev_host=set(['host', 'user']))

        # List of SQL tokens that must follow a WHERE statement
        self.post_where_tokens = ['GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET', 'PROCEDURE', 'INTO', 'FOR UPDATE']

        # Validate the information in data_sources is complete
        # so we can provide the caller with useful messaging
        # regarding what is missing when a class is instantiated.
        self.validate_data_source(data_source_name)

        self.pretty_sql_regex = re.compile('\s+', re.DOTALL)

        self.default_placeholder = '?'

        __all__ = ['load_procs',  # noqa
                   'get_proc',
                   'get_data',
                   'validate_data_source',
                   'set_execute_rules',
                   'get_execute_data']
开发者ID:digideskio,项目名称:datasource,代码行数:88,代码来源:RDBSHub.py


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