runSqlScript method

Future<CliResult> runSqlScript({
  1. required String user,
  2. required String database,
  3. required String scriptFilepath,
  4. String? host,
  5. int? port,
  6. String? password,
})

Implementation

Future<CliResult> runSqlScript({
  required String user,
  required String database,
  required String scriptFilepath,
  String? host,
  int? port,
  String? password,
}) async {
  // The path seperator must be '/' for the "source filename" statement.
  final posixScriptFilepath =
      checkFileExists(scriptFilepath, "scriptFilepath").absolutePosixPath;

  return _execute(
    // We do not need to encapsulate the script filepath in double/single
    // quotes. Actually doing that only causes errors.
    statement: "source $posixScriptFilepath;",
    user: user,
    database: database,
    password: password,
    host: host,
    port: port,
    extraArgs: [
      "--abort-source-on-error",
    ],
  );
}