-
Hi! I use func (s *Router) StoreVideos(conn *sqlite.Conn, videos map[string]*Video) error {
endFn, err := sqlitex.ImmediateTransaction(conn)
if err != nil {
return fmt.Errorf("error creating a transaction: %w", err)
}
defer endFn(&err)
stmt := conn.Prep("INSERT INTO videos (id, uploaded, title, views, vertical, category) VALUES (?, ?, ?, ?, ?, ?);")
for _, video := range videos {
stmt.BindText(1, video.ID)
stmt.BindInt64(2, video.UploadedAt)
stmt.BindText(3, video.Title)
stmt.BindInt64(4, int64(video.Views))
stmt.BindBool(5, video.Vertical)
stmt.BindInt64(6, int64(video.Category))
if _, err := stmt.Step(); err != nil {
return fmt.Errorf("stmt.Step: %w", err)
}
if err := stmt.Reset(); err != nil {
return fmt.Errorf("stmt.Reset: %w", err)
}
if err := stmt.ClearBindings(); err != nil {
return fmt.Errorf("stmt.ClearBindings: %w", err)
}
}
return nil
} I googled that I had to clear bindings everytime, but as you see there already is Any ideas of how could i fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The error you're seeing is what happens when a statement is interrupted by its interrupt channel. That's usually set by the pool when you use |
Beta Was this translation helpful? Give feedback.
The error you're seeing is what happens when a statement is interrupted by its interrupt channel. That's usually set by the pool when you use
Get
with the request's context. These sorts of errors are to be expected.