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


Python BaseHub.addDataSource方法代码示例

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


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

示例1: __init__

# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import addDataSource [as 别名]
   def __init__(self, sqlFileName):

      self.DATAZILLA_DATABASE_NAME     = os.environ["DATAZILLA_DATABASE_NAME"]
      self.DATAZILLA_DATABASE_USER     = os.environ["DATAZILLA_DATABASE_USER"]
      self.DATAZILLA_DATABASE_PASSWORD = os.environ["DATAZILLA_DATABASE_PASSWORD"]
      self.DATAZILLA_DATABASE_HOST     = os.environ["DATAZILLA_DATABASE_HOST"]
      self.DATAZILLA_DATABASE_PORT     = os.environ["DATAZILLA_DATABASE_PORT"]

      self.sqlFileName = sqlFileName

      try:
         self.DEBUG = os.environ["DATAZILLA_DEBUG"] is not None
      except KeyError:
         self.DEBUG = False

      self.rootPath = os.path.dirname(os.path.abspath(__file__))

      ####
      #Configuration of datasource hub:
      #	1 Build the datasource struct
      # 	2 Add it to the BaseHub
      #	3 Instantiate a MySQL hub for all derived classes
      ####
      dataSource = { self.DATAZILLA_DATABASE_NAME : { "hub":"MySQL",
                                                      "master_host":{"host":self.DATAZILLA_DATABASE_HOST,
                                                                     "user":self.DATAZILLA_DATABASE_USER,
                                                                     "passwd":self.DATAZILLA_DATABASE_PASSWORD},
                                                                     "default_db":self.DATAZILLA_DATABASE_NAME,
                                                      "procs": ["%s%s%s" % (self.rootPath,  "/sql/", sqlFileName)]
                                                    } }
      BaseHub.addDataSource(dataSource)
      self.dhub = MySQL(self.DATAZILLA_DATABASE_NAME)
开发者ID:rhelmer,项目名称:datazilla,代码行数:34,代码来源:Model.py

示例2: loadvars

# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import addDataSource [as 别名]
    def loadvars():

        #####
        #Only load the database sources once when the module
        #is imported
        #####
        if not Model.projectHub:

            Model.DATAZILLA_DATABASE_NAME = settings.DATAZILLA_DATABASE_NAME
            Model.DATAZILLA_DATABASE_USER = settings.DATAZILLA_DATABASE_USER
            Model.DATAZILLA_DATABASE_PASSWORD = settings.DATAZILLA_DATABASE_PASSWORD
            Model.DATAZILLA_DATABASE_HOST = settings.DATAZILLA_DATABASE_HOST
            Model.DATAZILLA_DATABASE_PORT = settings.DATAZILLA_DATABASE_PORT

            ####
            #Configuration of datasource hub:
            # 1 Build the datasource struct
            # 2 Add it to the BaseHub
            # 3 Instantiate a MySQL hub for all derived classes
            ####
            Model.rootPath = os.path.dirname(os.path.abspath(__file__))

            dataSource = { Model.DATAZILLA_DATABASE_NAME :

                            { "hub":"MySQL",
                              "master_host":

                                { "host":Model.DATAZILLA_DATABASE_HOST,
                                  "user":Model.DATAZILLA_DATABASE_USER,
                                  "passwd":Model.DATAZILLA_DATABASE_PASSWORD
                                },

                              "default_db":Model.DATAZILLA_DATABASE_NAME,
                              "procs": ["%s/%s" % (Model.rootPath,
                                                   'sources.json')]
                         } }

            BaseHub.addDataSource(dataSource)
            dzHub = MySQL(Model.DATAZILLA_DATABASE_NAME)

            Model.databaseSources = dzHub.execute(proc='sources.get_datasources',
                                                  key_column='project',
                                                  return_type='dict')

            Model.loadProjectHub(Model.databaseSources)
开发者ID:carljm,项目名称:datazilla,代码行数:47,代码来源:model.py

示例3: loadProjectHub

# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import addDataSource [as 别名]
    def loadProjectHub(databaseSources):

        for s in databaseSources:

            project = databaseSources[s]['project']

            dataSource = { project :
                { "hub":"MySQL",
                  "master_host":{"host":databaseSources[s]['host'],
                  "user":Model.DATAZILLA_DATABASE_USER,
                  "passwd":Model.DATAZILLA_DATABASE_PASSWORD},
                  "default_db":databaseSources[s]['name'],
                  "procs": ["%s/%s" % (Model.rootPath, 'graphs.json')]
                } }

            BaseHub.addDataSource(dataSource)
            hub = MySQL( project )
            Model.projectHub[ project ] = hub
开发者ID:carljm,项目名称:datazilla,代码行数:20,代码来源:model.py

示例4: _get_dhub

# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import addDataSource [as 别名]
    def _get_dhub(self):
        dataSource = {
            self.project : {
                "hub":"MySQL",
                "master_host":{
                    "host": settings.CLOUDSQL_INSTANCE,
                    # FIXME: CloudSQL has no users, but datasource requires it
                    "user": "none",
                    },
                "default_db": settings.CLOUDSQL_DATABASE,
                "procs": [os.path.join(SQL_PATH, self.procs_file_name)]
                }
            }
        BaseHub.addDataSource(dataSource)

        try:
            return CloudSQL(self.project)
        except KeyError:
            raise KeyError("Failed to create CloudSQL")
开发者ID:ctalbert,项目名称:datazilla,代码行数:21,代码来源:model.py

示例5: dhub

# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import addDataSource [as 别名]
    def dhub(self, procs_file_name):
        """
        Return a configured ``DataHub`` using the given SQL procs file.

        """
        data_source = {
            self.key: {
                "hub": "MySQL",
                "master_host": {
                    "host": self.host,
                    "user": settings.DATAZILLA_DATABASE_USER,
                    "passwd": settings.DATAZILLA_DATABASE_PASSWORD,
                    },
                "default_db": self.name,
                "procs": [os.path.join(SQL_PATH, procs_file_name)],
                }
            }
        BaseHub.addDataSource(data_source)
        # @@@ the datahub class should depend on self.type
        return MySQL(self.key)
开发者ID:ctalbert,项目名称:datazilla,代码行数:22,代码来源:models.py


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