MCPcopy
hub / github.com/jmoiron/sqlx / MustBeginTx

Method MustBeginTx

sqlx_context.go:183–189  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

181// transaction. Tx.Commit will return an error if the context provided to
182// MustBeginContext is canceled.
183func (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.

Callers 2

TestNamedContextQueriesFunction · 0.80

Calls 1

BeginTxxMethod · 0.95

Tested by 2

TestNamedContextQueriesFunction · 0.64