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)
| 96 | // queries will be difficult to get right, and its current driver-specific behavior |
| 97 | // is deemed at least not complex in its incorrectness. |
| 98 | func 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. |
nothing calls this directly
no test coverage detected