Пример #1
0
def add_foreign_keys_process():
    dump_date = get_dump_date(MYSQL, ARCHIVES_BASE_FOLDER)
    mysql = MySQL(dump_date)
    mysql.optimize_load()
    foreign_key_file = open(FOREIGN_KEYS_FILE, 'r').read()
    mysql.execute_file(foreign_key_file)
    mysql.disconnect()
Пример #2
0
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()
Пример #3
0
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()