mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-06 05:30:12 -06:00
Improve format_sql(): use sqlparse.format()
This commit is contained in:
@@ -11,6 +11,12 @@ try:
|
||||
except ImportError:
|
||||
HAVE_PYGMENTS = False
|
||||
|
||||
try:
|
||||
import sqlparse
|
||||
HAVE_SQLPARSE = True
|
||||
except ImportError:
|
||||
HAVE_SQLPARSE = False
|
||||
|
||||
|
||||
from flask import current_app
|
||||
|
||||
@@ -46,6 +52,9 @@ def format_fname(value):
|
||||
return '<%s>' % path
|
||||
|
||||
def format_sql(query, args):
|
||||
if HAVE_SQLPARSE:
|
||||
query = sqlparse.format(query, reindent=True, keyword_case='upper')
|
||||
|
||||
if not HAVE_PYGMENTS:
|
||||
return query
|
||||
|
||||
|
||||
Reference in New Issue
Block a user