go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

Add line number to error message when executing blob of sql

Open jbeder opened this issue 9 months ago • 1 comments

I'm running a blob of sql line this:

if _, err := db.ExecContext(ctx, statement); err != nil {
  return err
}

and I'm getting FOREIGN KEY constraint failed; but it's a giant blob of sql with many insert statements, so I sorta have to do trial and error to figure out which constraint is failing. Is it possible to add a line number to this error message?

jbeder avatar Mar 12 '25 14:03 jbeder

The sqlite3_error_offset function added in 3.38.0 seems like it would suit your needs.

rittneje avatar Mar 12 '25 15:03 rittneje