网站设计公司建设网站,页面访问维护,红旗渠建设集团网站,国家工信部网站备案我是一个从未使用过任何并行处理方法的新手。我希望从SQL Server读取大量数据(即至少200万行)#xff0c;并希望使用并行处理来加快读取速度。下面是我使用并发未来进程池进行并行处理的尝试。在class DatabaseWorker(object):def __init__(self, connection_string, n, resul…我是一个从未使用过任何并行处理方法的新手。我希望从SQL Server读取大量数据(即至少200万行)并希望使用并行处理来加快读取速度。下面是我使用并发未来进程池进行并行处理的尝试。在class DatabaseWorker(object):def __init__(self, connection_string, n, result_queue []):self.connection_string connection_stringstmt select distinct top %s * from dbo.KrishAnalyticsAllCalls %(n)self.query stmtself.result_queue result_queuedef reading(self,x):return(x)def pooling(self):t1 time.time()con pyodbc.connect(self.connection_string)curs con.cursor()curs.execute(self.query)with concurrent.futures.ProcessPoolExecutor(max_workers8) as executor:print(Test1)future_to_read {executor.submit(self.reading, row): row for row in curs.fetchall()}print(Test2)for future in concurrent.futures.as_completed(future_to_read):print(Test3)read future_to_read[future]try:print(Test4)self.result_queue.append(future.result())except:print(Not working)print(\nTime take to grab this data is %s %(time.time() - t1))df DatabaseWorker(rdriver{SQL Server}; serverSPROD_RPT01; databaseReporting;, 2*10**7)df.pooling()我当前的实现没有得到任何输出。Test1打印就这样。没有其他事情发生。我理解并发未来文档提供的各种示例但我无法在这里实现它。我将非常感谢你的帮助。谢谢您。在