def shopCode(shopCity): sql = "SELECT DISTINCT(shopPower) from dazhongfood ;" data = mysqlReturn(sql) list_code = [] for i in data: sql2 = '''SELECT COUNT(shopId) from dazhongfood where shopPower=%s and city="%s";'''%(i[0],shopCity) data_city = mysqlReturn(sql2) for j in data_city: list_code.append([i[0], j[0]]) print(list_code) return list_code
def foodRangingCity(city): sql = '''SELECT shopName,tasteScore,environmentScore,serviceScore,(tasteScore+environmentScore+serviceScore)/3.0 as avg from dazhongfood WHERE city="%s" GROUP BY (tasteScore+environmentScore+serviceScore)/3.0 DESC;''' % ( city) listData = mysqlReturn(sql) listShopName = [] listTasteScore = [] listEnvironmentScore = [] listServiceScore = [] listAvg = [] for data in listData: listShopName.append(data[0]) listTasteScore.append(int(data[1])) listEnvironmentScore.append(int(data[2])) listServiceScore.append(int(data[3])) listAvg.append(round(data[4], 2)) return [ listShopName, listTasteScore, listEnvironmentScore, listServiceScore, listAvg ]
def foodClassarea(city): sql = '''SELECT COUNT(mainCategoryName),mainCategoryName from dazhongfood where city="%s" GROUP BY mainCategoryName;''' % ( city) listData = mysqlReturn(sql) return listData
def foodClassinif(city): sql = '''SELECT COUNT(mainRegionName),mainRegionName from dazhongfood where city="%s" GROUP BY mainRegionName;''' % ( city) listData = mysqlReturn(sql) return listData
def foodRangingCity(shopName): sql = '''SELECT city, shopUrl,shopName,(tasteScore+environmentScore+serviceScore)/3.0 as avg,shopPower,mainRegionName,mainCategoryName,tasteScore,environmentScore,serviceScore,avgPrice,shopAddress from dazhongfood where city="%s" GROUP BY (tasteScore+environmentScore+serviceScore)/3.0 DESC limit 10; ''' % (shopName) listData = mysqlReturn(sql) return listData
def foodRangingCity(city, shopName): sql = '''SELECT shopName,tasteScore,environmentScore,serviceScore,avgPrice,shopPower from dazhongfood WHERE city="%s" and shopName="%s";''' % ( city, shopName) listData = mysqlReturn(sql) return listData