def get_more_restaurants(query,num): db=DataBase() morequery = query.replace('DESC LIMIT 5',f'DESC LIMIT 5 OFFSET {num}') df=db.fetch_restaurants_by_sql(morequery) print("SQL Query: " + morequery) return df
def get_restaurant(type,region,aspects): db=DataBase() query = "SELECT rest_name, rest_address, rest_region, AVG(rest_food_rating) as rest_food_rating, AVG(rest_srvc_rating) as rest_srvc_rating, AVG(rest_ambi_rating) as rest_ambi_rating, AVG(rest_prce_rating) as rest_prce_rating, AVG(w_rest_rating) as w_rest_rating FROM restaurant" query = query + searchby_foodtype_region(type,region) + sort_by_aspect(aspects) df=db.fetch_restaurants_by_sql(query) print("SQL Query: " + query) return df,query
def routine(): # url = ['https://store.steampowered.com/app/578080/PLAYERUNKNOWNS_BATTLEGROUNDS/', # 'https://store.steampowered.com/app/570/Dota_2/'] HC = HeadLessChrome() SP = SoupParser() DB = DataBase() # TEST HERE # HC.get_soup('https://store.steampowered.com/app/671210/FINAL_FANTASY_XV_WINDOWS_EDITION_PLAYABLE_DEMO/') applist = DB.get_applist(table='watching_games') num_applist = len(applist) for idx, app in enumerate(applist): appid, name = app if idx % 50 == 0: HC.reconn() print('--------------', idx, '/', num_applist, '--------------') try: print(appid, name) url = 'https://store.steampowered.com/app/' + str(appid) soup = HC.get_soup(url) if soup is None: continue result = SP.parse(soup) result['appid'] = appid result['name'] = name try: DB.insert_data(result) except: # logging print('DB ERROR') except: print("skip ", appid, name, '\n') HC.reconn() continue print(datetime.now())
from database.DataBase import DataBase from generator.Simulator import Simulator from acqusition.Station import Station from storage.Storage import Storage from query.Query import Query from analysis.Analysis import Analysis db = DataBase() # generate dataset generators = [] for i in range(2): generator = Simulator(type='simulator', item='item_A', name='Temperature') generator.encode() generators.append(generator) # acqusition station = Station(generators) station.collect_station_datas() # storage storage = Storage(db, station) storage.storage() # query query = Query(storage.session) query.query() # Analysis analysis = Analysis(query.data_frame) analysis.analysis()
# Prompt user before re-scoring DB _in1 = input( "Do you really want to re-score the current DB? Enter yes/no: ") if _in1.lower() == 'yes': print("Starting to re-score DB.") else: print("Bye!") sys.exit() db = None try: # create DataBase object db = DataBase( 'C:\\NUS_ISS_MTech\Year 2\Semester 2 - Practical Natural Language Processing\PLP CA\database\gastrotommy_v3.db' ) conn = db.connect_to_db() # select max record id id_sql = " SELECT MAX(id) FROM restaurant; " cur = conn.cursor() cur.execute(id_sql) rows = cur.fetchall() last_row_id = rows[0][0] print("last_row_id:", last_row_id) for i in range(1, last_row_id + 1): print("updating row with id:", i)