I have a print that works perfectly to me since I use tabulate:
print(tabulate(query, headers= 'keys', tablefmt = 'psql'))
And I would like to export this print to a txt file just the way it looks in terminal.
Thanks for your support!
Try in this way
print(tabulate(query, headers= 'keys', tablefmt = 'psql'), file=open("output.txt", "a"))