第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使用pyodbc加快從CSV到MS SQL Server的批量插入

如何使用pyodbc加快從CSV到MS SQL Server的批量插入

以下是我需要幫助的代碼。我必須在1,300,000行以上運(yùn)行它,這意味著最多需要40分鐘才能插入?300,000行。我認(rèn)為批量插入是加快速度的途徑嗎?還是因?yàn)槲乙ㄟ^for data in reader:部分遍歷行?#Opens the prepped csv filewith open (os.path.join(newpath,outfile), 'r') as f:    #hooks csv reader to file    reader = csv.reader(f)    #pulls out the columns (which match the SQL table)    columns = next(reader)    #trims any extra spaces    columns = [x.strip(' ') for x in columns]    #starts SQL statement    query = 'bulk insert into SpikeData123({0}) values ({1})'    #puts column names in SQL query 'query'    query = query.format(','.join(columns), ','.join('?' * len(columns)))    print 'Query is: %s' % query    #starts curser from cnxn (which works)    cursor = cnxn.cursor()    #uploads everything by row    for data in reader:        cursor.execute(query, data)        cursor.commit()我有目的地動(dòng)態(tài)地選擇列標(biāo)題(因?yàn)槲蚁雱?chuàng)建盡可能多的pythonic代碼)。SpikeData123是表名。
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 1069 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)