generate functionMon, 06 Feb 2023

transfer one million table records in 10,000 increments with select fields from mysql to postgresql

def migrate_records(table_name, source_database, target_database): ''' migrate records of one table from mysql to postgresql with incremental migration ''' row_count = source_database.get_row_count(table_name) iteration_count = int(row_count/10000) for i in range(iteration_count): start = i * 10000 end = start + 10000 records = source_database.get_records(table_name, start, end) target_database.insert_records(table_name, records)

Questions about programming?Chat with your personal AI assistant