本文整理汇总了Python中explorer.models.Query类的典型用法代码示例。如果您正苦于以下问题:Python Query类的具体用法?Python Query怎么用?Python Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Query类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self, request):
sql = request.POST.get("sql", None)
if not sql:
return PlayQueryView.render(request)
query = Query(sql=sql, title="Playground")
query.log(request.user)
return self.render_with_sql(request, query)
开发者ID:roojoom,项目名称:django-sql-explorer,代码行数:7,代码来源:views.py
示例2: post
def post(self, request):
sql = request.POST.get('sql', None)
if not sql:
return PlayQueryView.render(request)
query = Query(sql=sql, title="Playground")
query.params = url_get_params(request)
return self.render_with_sql(request, query)
开发者ID:winfieldco,项目名称:django-sql-explorer,代码行数:7,代码来源:views.py
示例3: post
def post(self, request, *args, **kwargs):
sql = request.POST.get('sql')
connection = request.POST.get('connection')
query = Query(sql=sql, connection=connection, title='')
ql = query.log(request.user)
query.title = 'Playground - %s' % ql.id
return _export(request, query)
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:7,代码来源:views.py
示例4: post
def post(self, request):
sql = request.POST.get('sql')
database = request.POST.get('database')
show_results = request.POST.get('show', True)
query = Query(sql=sql, title="Playground", database=database)
query.log(request.user)
return self.render_with_sql(request, query, show_results)
开发者ID:sevikkk,项目名称:django-sql-explorer,代码行数:7,代码来源:views.py
示例5: csv_from_sql
def csv_from_sql(request):
sql = request.POST.get('sql', None)
if not sql:
return PlayQueryView.render(request)
query = Query(sql=sql)
query.params = url_get_params(request)
fn = generate_report_action()
return fn(None, None, [query, ])
开发者ID:winfieldco,项目名称:django-sql-explorer,代码行数:8,代码来源:views.py
示例6: post
def post(self, request):
sql = request.POST.get('sql')
show_results = request.POST.get('show', True)
query = Query(sql=sql, title="Playground")
passes_blacklist, failing_words = query.passes_blacklist()
error = MSG_FAILED_BLACKLIST % ', '.join(failing_words) if not passes_blacklist else None
run_query = not bool(error) if show_results else False
return self.render_with_sql(request, query, run_query=run_query, error=error)
开发者ID:grantmcconnaughey,项目名称:django-sql-explorer,代码行数:8,代码来源:views.py
示例7: validate
def validate(self, value):
query = Query(sql=value)
if not query.available_params():
error = query.error_messages()
if error:
raise ValidationError(
_(error),
params={'value': value},
code="InvalidSql"
)
开发者ID:azizmb,项目名称:django-sql-explorer,代码行数:10,代码来源:forms.py
示例8: validate
def validate(self, value):
"""
Ensure that the SQL passes the blacklist.
:param value: The SQL for this Query model.
"""
query = Query(sql=value)
passes_blacklist, failing_words = query.passes_blacklist()
error = MSG_FAILED_BLACKLIST % ', '.join(failing_words) if not passes_blacklist else None
if error:
raise ValidationError(
error,
code="InvalidSql"
)
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:18,代码来源:forms.py
示例9: validate
def validate(self, value):
"""
Ensure that the SQL passes the blacklist and executes. Execution check is skipped if params are present.
:param value: The SQL for this Query model.
"""
query = Query(sql=value)
error = MSG_FAILED_BLACKLIST if not query.passes_blacklist() else None
if not error and not query.available_params():
error = query.try_execute()
if error:
raise ValidationError(
_(error),
code="InvalidSql"
)
开发者ID:ersherr,项目名称:django-sql-explorer,代码行数:19,代码来源:forms.py
示例10: validate
def validate(self, value):
"""
Ensure that the SQL passes the blacklist and executes. Execution check is skipped if params are present.
:param value: The SQL for this Query model.
"""
query = Query(sql=value)
passes_blacklist, failing_words = query.passes_blacklist()
error = MSG_FAILED_BLACKLIST % ', '.join(failing_words) if not passes_blacklist else None
if not error and not query.available_params():
try:
query.execute_query_only()
except DatabaseError as e:
error = str(e)
if error:
raise ValidationError(
_(error),
code="InvalidSql"
)
开发者ID:grantmcconnaughey,项目名称:django-sql-explorer,代码行数:24,代码来源:forms.py
示例11: post
def post(self, request):
sql = request.POST.get('sql')
query = Query(sql=sql, title="Playground")
query.log(request.user)
return self.render_with_sql(request, query)
开发者ID:alrvivas,项目名称:rh_campo,代码行数:5,代码来源:views.py
示例12: download_from_sql
def download_from_sql(request):
sql = request.POST.get('sql')
query = Query(sql=sql, title='')
ql = query.log(request.user)
query.title = 'Playground - %s' % ql.id
return _export(request, query)
开发者ID:AnthonyGaruccio,项目名称:django-sql-explorer,代码行数:6,代码来源:views.py
示例13: test_playground_query_log
def test_playground_query_log(self):
query = Query(sql='select 1;', title="Playground")
query.log(None)
log = QueryLog.objects.first()
self.assertTrue(log.is_playground)
开发者ID:nickspacek,项目名称:django-sql-explorer,代码行数:5,代码来源:test_models.py
示例14: handle
def handle(self, **options):
if "explorer" in settings.INSTALLED_APPS:
from explorer.models import Query
queries = (
(
"All Interactive Users",
"""SELECT u.first_name, u.last_name, u.email, u.username, u.is_staff, u.is_superuser,
p.salutation, p.company, p.position_title, p.phone, p.address, p.address2,
p.member_number, p.city, p.state, p.zipcode, p.country, p.url, p.sex,
p.address_type, p.phone2, p.fax, p.work_phone, p.home_phone, p.mobile_phone,
p.notes, p.admin_notes
FROM auth_user u INNER JOIN profiles_profile p
ON u.id=p.user_id
WHERE u.is_active=True
AND p.status=True
AND p.status_detail='active'""",
),
(
"All Members",
"""SELECT u.first_name, u.last_name, u.email, u.username, u.is_staff, u.is_superuser,
p.salutation, p.company, p.position_title, p.phone, p.address, p.address2,
p.member_number, p.city, p.state, p.zipcode, p.country, p.url, p.sex,
p.address_type, p.phone2, p.fax, p.work_phone, p.home_phone, p.mobile_phone,
m.membership_type_id, m.renewal, m.certifications, m.work_experience,
m.referer_url, m.referral_source, m.join_dt, m.expire_dt, m.renew_dt,
m.primary_practice, m.how_long_in_practice, m.application_approved,
m.application_approved_dt, m.areas_of_expertise, m.home_state,
m.year_left_native_country, m.network_sectors, m.networking,
m.government_worker, m.government_agency, m.license_number,
m.license_state, m.status_detail
FROM auth_user u
INNER JOIN profiles_profile p
ON u.id=p.user_id
INNER JOIN memberships_membershipdefault m
ON m.user_id=u.id
WHERE u.is_active=True
AND p.status=True
AND m.status_detail <> 'archive'""",
),
(
"All Corporate Members",
"""SELECT cp.name, cp.address, cp.address2, cp.city, cp.state, cp.zip, cp.country,
cp.phone, cp.email, cp.url, cp.number_employees, cp.chapter, cp.tax_exempt,
cp.annual_revenue, cp.annual_ad_expenditure, cp.description, cp.expectations,
cp.notes, cp.referral_source, cp.ud1, cp.ud2, cp.ud3, cp.ud4, cp.ud5, cp.ud6,
cp.ud7, cp.ud8, cm.corporate_membership_type_id, cm.renewal, cm.renew_dt,
cm.join_dt, cm.expiration_dt, cm.approved, cm.admin_notes, cm.status_detail
FROM corporate_memberships_corpprofile cp
INNER JOIN corporate_memberships_corpmembership cm
ON cp.id=cm.corp_profile_id
WHERE cm.status_detail <> 'archive'""",
),
(
"All Users in a Specific Group (replace <YOUR GROUP ID> with your group id)",
"""SELECT ug.name, u.first_name, u.last_name, u.email, u.username, u.is_staff,
u.is_superuser, p.salutation, p.company, p.position_title, p.phone,
p.address, p.address2, p.member_number, p.city, p.state, p.zipcode,
p.country, p.url, p.sex, p.address_type, p.phone2, p.fax, p.work_phone,
p.home_phone, p.mobile_phone
FROM auth_user u INNER JOIN profiles_profile p
ON u.id=p.user_id INNER JOIN user_groups_groupmembership ugm
on u.id=ugm.member_id INNER JOIN user_groups_group ug on ug.id=ugm.group_id
WHERE ug.id=<YOUR GROUP ID>
AND ugm.status=True
AND ugm.status_detail='active'""",
),
)
for title, sql in queries:
query = Query(title=title, sql=sql)
query.save()
print "Inserted: ", title
else:
print "NO default sqls loaded for SQL Explorer because django-sqlexplorer is not installed"
开发者ID:ZHW123,项目名称:tendenci,代码行数:75,代码来源:load_sqlexplorer_defaults.py
注:本文中的explorer.models.Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论