-
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.
Answered by
zombiezen
Jan 18, 2024
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.
2 replies
Answer selected by
thedmdim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.