I have a script that needs to insert a huge amount of data to the database (270k rows) and I'm using prepared statements (with for loops).
And when I execute (res, err := stmt.Exec
) I can retrieve the last ID that was inserted to the database (id, err = res.LastInsertId()
).
But since I'm making a-lot of requests to the database, after 16k rows I get max_prepared_statements(16,382) error
(which I then tried to set the max value to 1 million instead of 16,382 but the problem still remains).
My question is if there's another way to insert to DB and retrieve the last inserted ID without using prepared statements?
my insert code as for now is:
stmt, err := db.Prepare(`INSERT info SET title=?,minimage=?,downloadfile=?,rating=?,peoplewatched=?,likes=?`)
checkErr(err)
res, err := stmt.Exec(title,minimage,downloadfile,rating,peoplewatched,likes)
checkErr(err)
id, err = res.LastInsertId()
checkErr(err)
fmt.Println(id)
Thanks