MustBeginTx starts a transaction, and panics on error. Returns an *sqlx.Tx instead of an *sql.Tx. The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. Tx.Commit will return an error if the contex
(ctx context.Context, opts *sql.TxOptions)
| 181 | // transaction. Tx.Commit will return an error if the context provided to |
| 182 | // MustBeginContext is canceled. |
| 183 | func (db *DB) MustBeginTx(ctx context.Context, opts *sql.TxOptions) *Tx { |
| 184 | tx, err := db.BeginTxx(ctx, opts) |
| 185 | if err != nil { |
| 186 | panic(err) |
| 187 | } |
| 188 | return tx |
| 189 | } |
| 190 | |
| 191 | // MustExecContext (panic) runs MustExec using this database. |
| 192 | // Any placeholder parameters are replaced with supplied args. |