from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=num_partitions) as executor:
futures = [executor.submit(insert_to_sql_server, partition) for partition in partitions]
for future in futures:
future.result()
with ThreadPoolExecutor(max_workers=num_partitions) as executor:
futures = [executor.submit(insert_to_oracle, partition) for partition in partitions]
# Ensure all futures are done
for future in futures:
future.result()
1条答案
按热度按时间6ovsh4lw1#
我会这样做:步骤1:对DataFrame进行分区
第2步:为SQL Server和Oracle定义插入函数
步骤3:使用ThreadPool并行插入