ibatis批量匯入mysql資料庫

2021-09-02 21:25:32 字數 754 閱讀 9212

工作中需要批量匯入excel資料到mysql資料庫中

excel資料量比較大,一次大概匯入1萬多條

用傳統的for迴圈匯入mysql資料庫的話,非常耗時,大概3分鐘左右

所有就需要用到批處理,核心演算法如下

/**

* 批量插入功能

*/@suppresswarnings("unchecked")

public void insertbatch(final listlist) catch (sqlexception e) finally catch (sqlexception e) catch (sqlexception e1)

e.printstacktrace();}}

}

ibatis sql檔案如下

1次匯入excel1萬多條資料,耗時大概3秒鐘

部分效果圖

Mysql批量匯入功能

最近做的乙個abp專案需要批量匯入資料到mysql,網上查詢了各種資料都沒實現,然後根據查詢的資料整合了一下,方法是用list集合轉化成datatable然後使用mysqlbulkcopy方式批量上傳資料,速度明顯快了許多 public int listtodatatable listlist,st...

csv批量匯入mysql

使用python將csv檔案批量匯入mysql 附上 coding utf 8 換成讀入pandas再讀進sql的方法 import pandas as pd import numpy as np import csv from pandas import series,dataframe 將csv...

Mysql批量匯出與批量匯入

批量匯出 1 如果想把雲伺服器上的mysql資料庫資料匯出到本地 只能使用 客戶端語句 在終端使用mysql u root p test e select loid from ana customer where localnet id 101000 101000 loid.txt 將表中資料匯出到...