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


Python QueryHistory.build方法代码示例

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


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

示例1: execute_and_watch

# 需要导入模块: from beeswax.models import QueryHistory [as 别名]
# 或者: from beeswax.models.QueryHistory import build [as 别名]
  def execute_and_watch(self, query, design=None, notify=False):
    """
    Run query and return a QueryHistory object in order to see its progress on a Web page.
    """
    query_statement = query.query['query']
    query_history = QueryHistory.build(
                                owner=self.client.user,
                                query=query_statement,
                                server_host='%(server_host)s' % self.client.query_server,
                                server_port='%(server_port)d' % self.client.query_server,
                                server_name='%(server_name)s' % self.client.query_server,
                                server_type=self.server_type,
                                last_state=QueryHistory.STATE.submitted.index,
                                design=design,
                                notify=notify)
    query_history.save()

    LOG.debug("Made new QueryHistory id %s user %s query: %s..." % (query_history.id, self.client.user, query_history.query[:25]))

    try:
      handle = self.client.query(query)
      if not handle.is_valid():
        msg = _("Server returning invalid handle for query id %(id)d [%(query)s]...") % \
              {'id': query_history.id, 'query': query_statement[:40]}
        raise BeeswaxException(msg)
    except BeeswaxException, ex: # TODO HS2
      LOG.exception(ex)
      # Kind of expected (hql compile/syntax error, etc.)
      if hasattr(ex, 'handle') and ex.handle:
        query_history.server_id = ex.handle.id
        query_history.log_context = ex.handle.log_context
      query_history.save_state(QueryHistory.STATE.failed)
      raise ex
开发者ID:icheckmate,项目名称:hue,代码行数:35,代码来源:dbms.py

示例2: execute_query

# 需要导入模块: from beeswax.models import QueryHistory [as 别名]
# 或者: from beeswax.models.QueryHistory import build [as 别名]
    def execute_query(self, query, design):
        from beeswax.models import QueryHistory

        sql_query = query.sql_query
        query_history = QueryHistory.build(
            owner=self.client.user,
            query=sql_query,
            server_host="%(server_host)s" % self.client.query_server,
            server_port="%(server_port)d" % self.client.query_server,
            server_name="%(server_name)s" % self.client.query_server,
            server_type=self.server_type,
            last_state=QueryHistory.STATE.available.index,
            design=design,
            notify=False,
            query_type=query.query["type"],
            statement_number=0,
        )
        query_history.save()

        LOG.debug(
            "Updated QueryHistory id %s user %s statement_number: %s"
            % (query_history.id, self.client.user, query_history.statement_number)
        )

        return query_history
开发者ID:shobull,项目名称:hue,代码行数:27,代码来源:dbms.py

示例3: execute_and_watch

# 需要导入模块: from beeswax.models import QueryHistory [as 别名]
# 或者: from beeswax.models.QueryHistory import build [as 别名]
    def execute_and_watch(self, query, design=None, query_history=None):
        """
    Run query and return a QueryHistory object in order to see its progress on a Web page.
    """
        hql_query = query.hql_query
        if query_history is None:
            query_history = QueryHistory.build(
                owner=self.client.user,
                query=hql_query,
                server_host="%(server_host)s" % self.client.query_server,
                server_port="%(server_port)d" % self.client.query_server,
                server_name="%(server_name)s" % self.client.query_server,
                server_type=self.server_type,
                last_state=QueryHistory.STATE.submitted.index,
                design=design,
                notify=query.query.get("email_notify", False),
                query_type=query.query["type"],
                statement_number=0,
            )
            query_history.save()

            LOG.debug(
                "Made new QueryHistory id %s user %s query: %s..."
                % (query_history.id, self.client.user, query_history.query[:25])
            )

        try:
            handle = self.client.query(query, query_history.statement_number)
            if not handle.is_valid():
                msg = _("Server returning invalid handle for query id %(id)d [%(query)s]...") % {
                    "id": query_history.id,
                    "query": query[:40],
                }
                raise QueryServerException(msg)
        except QueryServerException, ex:
            LOG.exception(ex)
            # Kind of expected (hql compile/syntax error, etc.)
            if hasattr(ex, "handle") and ex.handle:
                query_history.server_id, query_history.server_guid = ex.handle.id, ex.handle.id
                query_history.log_context = ex.handle.log_context
            query_history.save_state(QueryHistory.STATE.failed)
            raise ex
开发者ID:cyc821211,项目名称:hue,代码行数:44,代码来源:dbms.py


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