本文整理汇总了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']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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):
"""
DEPRECATED!!!
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) + ':api_autocomplete', kwargs={}),
})
示例2: execute
# 需要导入模块: from beeswax.design import HQLdesign [as 别名]
# 或者: from beeswax.design.HQLdesign import _data_dict['query']['query'] [as 别名]
def execute(request, design_id=None):
response = {'status': -1, 'message': ''}
if request.method != 'POST':
response['message'] = _('A POST request is required.')
app_name = get_app_name(request)
query_server = get_query_server_config(app_name)
query_type = beeswax.models.SavedQuery.TYPES_MAPPING[app_name]
design = safe_get_design(request, query_type, design_id)
try:
query_form = get_query_form(request)
if query_form.is_valid():
query_str = query_form.query.cleaned_data["query"]
explain = request.GET.get('explain', 'false').lower() == 'true'
design = save_design(request, query_form, query_type, design, False)
if query_form.query.cleaned_data['is_parameterized']:
# Parameterized query
parameterization_form_cls = make_parameterization_form(query_str)
if parameterization_form_cls:
parameterization_form = parameterization_form_cls(request.REQUEST, prefix="parameterization")
if parameterization_form.is_valid():
parameters = parameterization_form.cleaned_data
real_query = substitute_variables(query_str, parameters)
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, design, query_server, parameters=parameters)
except Exception, ex:
db = dbms.get(request.user, query_server)
error_message, log = expand_exception(ex, db)
response['message'] = error_message
return JsonResponse(response)
else:
response['errors'] = parameterization_form.errors
return JsonResponse(response)
# Non-parameterized query
query = HQLdesign(query_form, query_type=query_type)
if request.GET.get('explain', 'false').lower() == 'true':
return explain_directly(request, query, design, query_server)
else:
return execute_directly(request, query, design, query_server)
else:
示例3: _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)
query_form.bind(params)
assert query_form.is_valid()
query_str = query_form.query.cleaned_data["query"]
query_server = get_query_server_config(get_app_name(request))
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._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': json.dumps({}),
})