bulkwrite 批量插入

rt : begin->prepare->(in loop exec)->commit

并没有详细介绍用法和原理,笔者在开发业务时使用的库是sqlx[2],sql也支持clickhouse-go驱动。参考了官方样例代码[3]

...tx, err := connect.Begin()checkErr(err)stmt, err := tx.Prepare("INSERT INTO example (country_code, os_id, browser_id, categories, action_day, action_time) VALUES (?, ?, ?, ?, ?, ?)")checkErr(err)

for i := 0; i 100; i++ { if _, err := stmt.Exec(  "RU",  10+i,  100+i,  []int16{1, 2, 3},  time.Now(),  time.Now(),
(0)

相关推荐