Nice to have: reformat SQL code
The queries SQLAlchemy produces are a bit hard to read for humans. It might be interesting to optionally use sqlparse to reformat the query.
Generally like this idea.
However this does make scrolling the sqlapanel much much longer. if you use a lot of IN() selects, the current behavior puts each param of the array on a new line. (I just filed a feature request to disable that)
there are a few sqlaparse performance bugs that are unresolved, so I'm wary of integrating it on a large scale.
• https://github.com/andialbrecht/sqlparse/issues/135 • https://github.com/andialbrecht/sqlparse/issues/41
my quick test though made the screen decently better to look at.
sqla.py:
+ import sqlparse
+ def reformat_query(q):
+ return sqlparse.format(q, reindent=True, keyword_case='upper')
'duration': duration,
- 'statement': stmt,
+ 'statement': reformat_query(stmt),
'parameters': params,
If you look at long queries, most of the space is occupied by the column aliasing. We could truncate/fold the column list, while adding a ... button which would unfold on mouse click.
A CSS toggle button could make the page easier to use.
I use a custom module that runs sqlparse and am pretty happy with it as-is though