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

Function LoadFile

sqlx.go:707–718  ·  sqlx.go::LoadFile

LoadFile exec's every statement in a file (as a single call to Exec). LoadFile 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 for initializ

(e Execer, path string)

Source from the content-addressed store, hash-verified

705// queries will be difficult to get right, and its current driver-specific behavior
706// is deemed at least not complex in its incorrectness.
707func LoadFile(e Execer, path string) (*sql.Result, error) {
708 realpath, err := filepath.Abs(path)
709 if err != nil {
710 return nil, err
711 }
712 contents, err := ioutil.ReadFile(realpath)
713 if err != nil {
714 return nil, err
715 }
716 res, err := e.Exec(string(contents))
717 return &res, err
718}
719
720// MustExec execs the query using e and panics if there was an error.
721// Any placeholder parameters are replaced with supplied args.

Callers

nothing calls this directly

Calls 1

ExecMethod · 0.65

Tested by

no test coverage detected