方法是导入pandas的库, 使用DataFram制表.
控制台直接显示返回的所有数据库数据:
#show food items
showFood = " select id,name,note,price from foodlist;"
result = cur.execute(showFood)
print("Welcome! We now have",result,"kinds of pizza now. "
"You could find the index number, name, price and note of our pizzas in the following table."
"Please feel free to order them! Thank you!")
for row in cur.fetchall():
print(row)
使用DataFrame绘制表格:
import pandas as pd
fd = pd.DataFrame(list(cur.fetchall()),columns=["index number","name","note","price"])
print(fd)