#cording:utf-8
#クエリー結果のtupleを分かりやすく表示
#1行検索結果の取得fetchone()
import wineshop
myhostdb = wineshop.getDB()
mycursor = myhostdb.cursor()
wid = input("何番目のワインのデータを知りたいか:")
mycursor.execute("select wineID,name,color, price,locality,country from wine inner join locality using(locaID) where wineID=%s",(wid,))
myresult = mycursor.fetchone()
#print(myresult)
#use index of the tuple
slist = ["wineID:","name:","color:", "price:","locality:","country:"]
for i in range(6):
print(slist[i],myresult[i])
print()
#unpacking the tuple
wineID,name,color, price,locality,country = myresult
print(slist[0]+str(wineID),slist[1]+name,slist[3]+str(price)+"円","税込:"+str(int(price*1.1))+"円")
mycursor.execute("select count(*) as res from wine where color='赤' ")
myresult = mycursor.fetchone()
print("\n 赤ワインの数:",myresult[0])
myhostdb.close()