I'm having some data stored in the SQL database table. I need to fetch all that data from the DB and print it as a python output in a human-readable format like an aligned table.
Below you can see I used fetchall()
method to fetch those data and used print
statement with 2 for
loops.
#executing all the records in the SQL query
cursor.execute("SELECT * FROM game_log")
#Fetch results using fetchall() method
data=cursor.fetchall()
print("\n\nDate&Time\t\tName\tWord\tTurns Given\tTurns Used\tResults")
print("================================================================================")
for item in data:
for value in item:
print(value,end="\t")
print()
Below you can see some of them are displaying as aligned but some of the data aren't displaying as aligned.
How to display all the data aligned?