#coding:utf-8
import connect
import os
mydb = connect.getDB()
mycursor = mydb.cursor()
while True:
os.system("clear")
cond = input(''' ワインの色:
r: 赤
w: 白
''')
if cond in ["r","w"]:
if cond == "r":
ans = "赤"
elif cond =="w":
ans = "白"
else:
ans = "ロゼ"
ord = input(''' 値段の表示順:
asc: 安い順
desc: 高い順
''')
if ord in ["asc","desc"]:
sql1 = "select wineID,name,concat(country, '・', locality), price from wine inner join locality using(locaID) "
sql = sql1 + " where color like '" + ans + "' order by price " + ord
print("----wine一覧----\n {}ワイン {}順\n".format(ans,ord))
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
yn = input("\n続けるならEnterキーを、やめるなら他のキーを ")
if yn != '':
break
mydb.close()