如何使用Golang的database.sql包批处理sql语句?
在Java中,我会这样做:
// Create a prepared statement
String sql = "INSERT INTO my_table VALUES(?)";
PreparedStatement pstmt = connection.prepareStatement(sql);
// Insert 10 rows of data
for (int i=0; i<10; i++) {
pstmt.setString(1, ""+i);
pstmt.addBatch();
}
// Execute the batch
int [] updateCounts = pstmt.executeBatch();
Run Code Online (Sandbox Code Playgroud)
我如何在Golang中实现同样的目标?