def testWriteToDb(self): db_path = "/Users/superCat/Desktop/PycharmProjectPortable/sync/FilteredSitesList" good_db = "/Users/superCat/Desktop/PycharmProjectPortable/sync/Majestic_filtering_good.csv" table = "20/12/2015 Legal" db = FilteredResultDB(table=table, offset=0, db_addr=db_path) count = 0 temp_sites = [] with open(good_db, mode='r', newline='') as csv_file: rd = csv.reader(csv_file, delimiter=',') for row in rd: if int(row[10]) > 1450612100: data = FilteredDomainData.from_tuple(row) print(data.__dict__) count += 1 temp_sites.append(data) print("total:", count) db.add_sites(temp_sites, skip_check=False) db.close()
def testFilterExportDB2(self): from_addr = "/Users/superCat/Desktop/PycharmProjectPortable/sync/FilteredSitesList.db" to_addr = "/Users/superCat/Desktop/PycharmProjectPortable/sync/Sum.db" table_name = "20/11/2015" from_db = FilteredResultDB(table_name, db_addr=from_addr) from_db.cur.execute("SELECT name FROM sqlite_master WHERE type = 'table';") table_names = [x[0] for x in from_db.cur.fetchall()] to_db = FilteredResultDB("2015 Old", db_addr=to_addr) for table_name in table_names: print(table_name) temp = FilteredResultDB(table_name, db_addr=from_addr) results = [x for x in temp.get_all_sites() if x[1] > 0] temp.close() count = 0 for item in results: print("count:", count, "item:", item) count += 1 to_db.add_sites(results, skip_check=True) from_db.close() to_db.close()