Currently I am trying to output some data from an SQLite database file into a command line but the data does not seem to be displaying correctly.
Currently when I input for the data to be displayed it outputs it like this:
Student Table
StudentID Name Year
1 Dan 13
2 Jake 13
3 Joe 13
4 David 13
I would like all of the names to be in line correctly or at least centered but I cannot figure out how to do it!
The code for the formatting is as follows:
def view():
con = lite.connect('records.db')
with con:
cur = con.cursor()
cur.execute('SELECT * FROM Student')
col_names = [cn[0] for cn in cur.description]
rows = cur.fetchall()
print("%20s" % ("Student Table"))
print("{0:1} {1:^10} {2:20}".format(col_names[0], col_names[1], col_names[2]))
for row in rows:
print("%5s %10s %7s" % (row))
display = menu.Menu.DisplayMenu("Student")
choice = GetMenuChoice()
ValidateMenuChoice(choice)
main(choice)
any help would be greatly appreciated!