本文整理汇总了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
示例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
示例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