0

how do I align all the values ​​in the middle of the query result?

print('\n\nThis is my first Query in Python\n')
print(tabulate(cursor, showindex=False, headers=cursor.columns))

this is the result:

enter image description here

luana nastasi
  • 29
  • 1
  • 4
  • Use the `numalign=` and/or `stralign=` named arguments to `tabulate()`. E.g. `tabulate(cursor, showindex=False, headers=cursor.columns, numalign="center")` – kindall Aug 06 '18 at 18:42

2 Answers2

0

Use numalign argument, like this:

print('\n\nThis is my first Query in Python\n')
print(tabulate(cursor, showindex=False, headers=cursor.columns, numalign='center'))
PixelEinstein
  • 1,713
  • 1
  • 8
  • 17
0

Someone asked the same question a while ago: Pretty Printing a pandas dataframe I will suggest you, to take a look on the last answer and also just try in your tabulate function: tablefmt='psql'

Al_Kapo
  • 38
  • 1
  • 6