def get_availability_paris(): bdd = Pablo() bdd.executerReq("SELECT id_airbnb FROM airbnb") lenght = len(bdd.resultatReq()) i = 11000 bdd.executerReq("SELECT id_airbnb FROM airbnb") for listing in bdd.resultatReq()[11000:]: print("%s on %s listings" % (i, lenght)) get_availability(listing[0]) time.sleep(0.5) i += 1
def main(): bdd = Pablo() insert_listing = """INSERT INTO airbnb_rev_june (listing_id, city) VALUES (%s, %s)""" # insertion des listings 20K bdd.executerReq("SELECT DISTINCT listing_id, city FROM airbnb_reviews_20k") listings = bdd.resultatReq() # print(listings) # bdd.cursor.executemany(insert_listing, listings) nb_rev = bdd.executerReq( """SELECT COUNT(id) as nb_rev, listing_id FROM airbnb_review_global WHERE date_creation > 20170531 and date_creation < 20170701 group by listing_id""" ) for elem in bdd.resultatReq(): bdd.exec_req_with_args( """UPDATE airbnb_rev_june SET nb_reviews = %s WHERE listing_id = %s""", (elem[0], elem[1]))
def get_users_paris(): bdd = Pablo() # bdd.executerReq("SELECT DISTINCT author_id FROM airbnb_review") # for user in bdd.resultatReq(): # get_user(user) bdd.executerReq("SELECT DISTINCT recipient_id FROM airbnb_review limit 3") for user in bdd.resultatReq(): get_user(user[0]) bdd.close()
def get_some_review_paris(): bdd = Pablo() i = 0 # bdd.executerReq("SELECT distinct listing_id from airbnb_reviews_20k order by id desc") req = """SELECT listing_id FROM airbnb_reviews_20k WHERE listing_id NOT IN (SELECT DISTINCT listing_id FROM airbnb_review_global WHERE date_creation > 20170531 AND date_creation < 20170701)""" bdd.executerReq(req) for listing in bdd.resultatReq()[::-1]: i += 1 id_listing = listing[0] print("listing number : %s" % i) get_all_reviews(id_listing) bdd.close()