Hi Niti, There's on need to build a giant SQL string; a transaction can span multiple statements. To bind in golang place a ? within your SQL query and provide the values as additional arguments to the Exec/Query function. eg, after using db.Begin() to create a transaction
tx, err := db.Begin() if err != nil { return err } _, err = tx.Exec("INSERT INTO table1 VALUES (?, ?, ?)", column1, column2, column3) if err != nil { tx.Rollback() return err } err = tx.Commit() if err != nil { return err } Note that golang's sql transaction abstraction doesn't map perfectly to sqlite. Golang does not allow any further operations on the Tx following a call to Tx.Commit() or Tx.Rollback(). But in sqlite a transaction remains open if COMMIT fails because the database is locked. If you want to be able to retry the COMMIT in this situation you must manually manage transactions via db.Exec("BEGIN")/db.Exec("COMMIT") instead of db.Begin()/tx.Commit(). -Rowan On 7 February 2017 at 13:36, Niti Agarwal <n...@ionosnetworks.com> wrote: > Hi, > We are using Sqlite3 with Golang to do bulk insert. > Need to insert close to 10 Million records to sqlite3 in around 30 mins. > > Currently I am saving 100 Records under one transaction with below > settings: > > PRAGMA synchronous = NORMAL; > PRAGMA journal_mode = WAL; > PRAGMA auto_vacuum = FULL; > > I read about SQLITE_MAX_SQL_LENGTH, Is it better to tune this value? > > Also, read about sql bind feature, but not very sure how to do in Golang? > Is there any better way to do bulk insert? > > Thanks, > Niti > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users