Skip to content

Instantly share code, notes, and snippets.

@johnny-godoy
Last active October 2, 2022 19:08
Show Gist options
  • Save johnny-godoy/532bca5509c810317febffe6354400c8 to your computer and use it in GitHub Desktop.
Save johnny-godoy/532bca5509c810317febffe6354400c8 to your computer and use it in GitHub Desktop.
Function for getting pretty-printable tables out of sqlalchemy queries
from __future__ import annotations
import tabulate
def tabulate_query(query: Query, **kwargs):
return tabulate.tabulate(query,
headers=(column.get('name') for column in query.column_descriptions),
**kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment