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

Function LoadFileContext

sqlx_context.go:98–109  ·  sqlx_context.go::LoadFileContext

LoadFileContext exec's every statement in a file (as a single call to Exec). LoadFileContext may return a nil *sql.Result if errors are encountered locating or reading the file at path. LoadFile reads the entire file into memory, so it is not suitable for loading large data dumps, but can be useful

(ctx context.Context, e ExecerContext, path string)

Source from the content-addressed store, hash-verified

96// queries will be difficult to get right, and its current driver-specific behavior
97// is deemed at least not complex in its incorrectness.
98func LoadFileContext(ctx context.Context, e ExecerContext, path string) (*sql.Result, error) {
99 realpath, err := filepath.Abs(path)
100 if err != nil {
101 return nil, err
102 }
103 contents, err := ioutil.ReadFile(realpath)
104 if err != nil {
105 return nil, err
106 }
107 res, err := e.ExecContext(ctx, string(contents))
108 return &res, err
109}
110
111// MustExecContext execs the query using e and panics if there was an error.
112// Any placeholder parameters are replaced with supplied args.

Callers

nothing calls this directly

Calls 1

ExecContextMethod · 0.65

Tested by

no test coverage detected