def insert_recommend_news(self): connection = setting() cursor = connection.cursor() cursor.execute(cursor.mogrify("TRUNCATE RECOMMEND_NEWS")) for i in range(len(self.title_lsit)): cursor.execute( cursor.mogrify( "INSERT INTO RECOMMEND_NEWS(recommend_id, news_title, news_url) VALUES (%s, %s, %s)", (int(i + 1), self.title_lsit[i], self.link_list[i]))) connection.commit() cursor.close() connection.close()
def getOrderForms(user_id): connection = setting() cursor = connection.cursor() cursor.execute( cursor.mogrify("Select * from order_form where user_id = %s", user_id)) results = cursor.fetchall() cursor.close() connection.close() datas = [] for row in results: data = {} data['id'] = row[0] #data['user_id'] = row[1] data['dish_id'] = row[2] data['restaurant_id'] = row[3] data['comment_id'] = row[4] data['time'] = row[5] datas.append(data) return datas
def searchDishes(words): connection = setting() cursor = connection.cursor() cursor.execute( cursor.mogrify("Select * from dish where name like %s", "%" + words + "%")) results = cursor.fetchall() cursor.close() connection.close() datas = [] for row in results: data = {} data['id'] = row[0] data['restaurant_id'] = row[1] data['name'] = row[2] data['price'] = row[3] data['photo_path'] = row[4] data['description'] = row[5] datas.append(data) return datas