def restore_old_users_data_process(): dump_date = get_dump_date(MYSQL, ARCHIVES_BASE_FOLDER) previous_mysql_dump_date = get_previous_dump_date(MYSQL, ARCHIVES_BASE_FOLDER) db_name = f"{GHTORRENT}-{previous_mysql_dump_date}" if dump_date != previous_mysql_dump_date: mysql = MySQL(f"{dump_date}") mysql.update_users(db_name) mysql.commit() mysql.disconnect()
def update_mysql_process(): dump_date = get_dump_date(MONGO, ARCHIVES_BASE_FOLDER) if is_dump_date_valid(dump_date): previous_mysql_dump_date = get_previous_dump_date( MYSQL, ARCHIVES_BASE_FOLDER) mysql = MySQL(previous_mysql_dump_date) db_name = f"{GHTORRENT}-{USERS_TEMP}" mysql.update_users(db_name) mysql.commit() mysql.disconnect()
def restore_users_schema_process(): dump_date = get_dump_date(MONGO, ARCHIVES_BASE_FOLDER) if is_dump_date_valid(dump_date): csv_file = os.path.join(ARCHIVES_BASE_FOLDER, f"{MONGO}-{USERS}-{dump_date}.csv") mysql = MySQL(USERS_TEMP) mysql.optimize_load() mysql.restore_users_schema(csv_file, USERS) mysql.commit() mysql.create_index_users_login() mysql.disconnect()
def process(table): global dump_date global file_destination mysql = MySQL(dump_date) mysql.optimize_load() print(f"processing table {table}") csv_file = f"{file_destination}/{table}.csv" mysql.restore_db(csv_file, table) print(f"finished processing file {table}") mysql.commit() mysql.disconnect()