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


Python HQLdesign._data_dict["query"]["query"]方法代码示例

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


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

示例1: _run_parameterized_query

# 需要导入模块: from beeswax.design import HQLdesign [as 别名]
# 或者: from beeswax.design.HQLdesign import _data_dict["query"]["query"] [as 别名]
def _run_parameterized_query(request, design_id, explain):
    """
  Given a design and arguments to parameterize that design, runs the query.
  - explain is a boolean to determine whether to run as an explain or as an
  execute.

  This is an extra "step" in the flow from execute_query.
  """
    design = authorized_get_design(request, design_id, must_exist=True)

    # Reconstitute the form
    design_obj = beeswax.design.HQLdesign.loads(design.data)
    query_form = QueryForm()
    params = design_obj.get_query_dict()
    params.update(request.POST)

    databases = _get_db_choices(request)
    query_form.bind(params)
    query_form.query.fields["database"].choices = databases  # Could not do it in the form

    if not query_form.is_valid():
        raise PopupException(_("Query form is invalid: %s") % query_form.errors)

    query_str = query_form.query.cleaned_data["query"]
    app_name = get_app_name(request)
    query_server = get_query_server_config(app_name)
    query_type = SavedQuery.TYPES_MAPPING[app_name]

    parameterization_form_cls = make_parameterization_form(query_str)
    if not parameterization_form_cls:
        raise PopupException(_("Query is not parameterizable."))

    parameterization_form = parameterization_form_cls(request.REQUEST, prefix="parameterization")

    if parameterization_form.is_valid():
        real_query = substitute_variables(query_str, parameterization_form.cleaned_data)
        query = HQLdesign(query_form, query_type=query_type)
        query._data_dict["query"]["query"] = real_query
        try:
            if explain:
                return explain_directly(request, query, design, query_server)
            else:
                return execute_directly(request, query, query_server, design)
        except Exception, ex:
            db = dbms.get(request.user, query_server)
            error_message, log = expand_exception(ex, db)
            return render(
                "execute.mako",
                request,
                {
                    "action": reverse(get_app_name(request) + ":execute_query"),
                    "design": design,
                    "error_message": error_message,
                    "form": query_form,
                    "log": log,
                    "autocomplete_base_url": reverse(get_app_name(request) + ":autocomplete", kwargs={}),
                },
            )
开发者ID:jriv96,项目名称:hue,代码行数:60,代码来源:views.py


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