Skip to content

Add line number to error message when executing blob of sql #1326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jbeder opened this issue Mar 12, 2025 · 1 comment
Open

Add line number to error message when executing blob of sql #1326

jbeder opened this issue Mar 12, 2025 · 1 comment

Comments

@jbeder
Copy link

jbeder commented Mar 12, 2025

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?

@rittneje
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants