We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`m := []UserTable{ {User: User{ Name: "tom1", Age: 12, Class: 10, }}, {User: User{ Name: "li1", Age: 22, Class: 10, }}, {User: User{ Name: "wang1", Age: 22, Class: 10, }}, {User: User{ Name: "wan", Age: 22, Class: 10, }}, }
if err = db.Model(&UserTable{}).CreateInBatches(&m,2).Error; err != nil { fmt.Println("插入数据异常: ", err) }`
当指定批量插入按照2条数据一组,进行批量插入,一共四条数据gorm底层库会分两批插入,但是发现clickhouse库会失败异常,具体原因可以使用的方式是: 如果指定批量插入的数据量必须大于总插入数据量进行一次性插入可以成功,一旦设置小于总量就会报错,请重点关注一下,这个异常不符合实际需求。
异常响应: code: 101, message: Unexpected packet Query received from client
The text was updated successfully, but these errors were encountered:
我大于总量也报错
后面将Session(&gorm.Session{SkipDefaultTransaction: true}).去了,没遇到了
Session(&gorm.Session{SkipDefaultTransaction: true}).
batchSize设置为了实际数据长度+1
Sorry, something went wrong.
蹲一个解决办法,小于总数据量会报;code: 101, message: Unexpected packet Query received from client
jinzhu
No branches or pull requests
GORM Playground Link
`m := []UserTable{
{User: User{
Name: "tom1",
Age: 12,
Class: 10,
}},
{User: User{
Name: "li1",
Age: 22,
Class: 10,
}},
{User: User{
Name: "wang1",
Age: 22,
Class: 10,
}},
{User: User{
Name: "wan",
Age: 22,
Class: 10,
}},
}
Description
当指定批量插入按照2条数据一组,进行批量插入,一共四条数据gorm底层库会分两批插入,但是发现clickhouse库会失败异常,具体原因可以使用的方式是: 如果指定批量插入的数据量必须大于总插入数据量进行一次性插入可以成功,一旦设置小于总量就会报错,请重点关注一下,这个异常不符合实际需求。
异常响应: code: 101, message: Unexpected packet Query received from client
The text was updated successfully, but these errors were encountered: