querybara run-file
- CLI
- PostgreSQL
- MySQL
- MariaDB
querybara run-file runs a SQL file against a target, one statement at a time, with progress. It
stops at the first failed statement, or with --continue goes on and reports the failures at the
end. The file may be gzipped. Use it for migrations and for loading dumps.
Usage: querybara run-file [options] <target> <file>
run a .sql file statement by statement with progress and an error log
Arguments: target profile name or id, or connection URI file the SQL file (gzip allowed)
Options: --continue keep going after a failed statement (default: stop) --error-log <file> write failed statements and their errors to a file --encoding <name> text encoding (default: detected) --database <name> database to connect to --read-only refuse statements that write -y, --yes run statements that need confirmation without asking --tls <mode> TLS mode for this run: disable, require, verify-ca or verify-full --ssh <user@host[:port]> reach URI targets through this SSH server; repeat for jump hosts, in order --ssh-key <path> SSH private key file (OpenSSH, PEM or PuTTY .ppk) --ssh-password-env <VAR> take the SSH password from this variable (default QUERYBARA_SSH_PASSWORD, else a prompt) --ssh-agent log in with the keys of ssh-agent (SSH_AUTH_SOCK) or Pageant --proxy <url> reach URI targets (or their first SSH server) through socks5://host:port or http://host:port --ssh-accept-new trust and remember an SSH host key not seen before (a changed key is always refused) --known-hosts <path> SSH known hosts file (default: the desktop app's) -h, --help show help for a command
The file streams through the statement splitter (DELIMITER, dollar quoting and comments arehandled), so multi-gigabyte dumps run in flat memory; result rows are discarded (use`querybara query -f` to see them). Statements run as the file says, its own BEGIN/COMMITincluded.
Exit codes: 0 every statement ran, 1 some failed with --continue, 2 stopped at a failure,130 interrupted. Safety as for query: risky statements and, on production profiles, everywrite need --yes or a confirmation; read-only targets refuse writes.
Examples: querybara run-file dev migrate.sql querybara run-file "postgres://app@localhost/app" dump.sql.gz --continue --error-log errors.logThe --tls and SSH options are described in
Global options.
Examples
Section titled “Examples”querybara run-file shop-dev migrate.sqlquerybara run-file shop-dev migrate.sql --continuequerybara run-file "postgres://[email protected]/shop" dump.sql.gz --continue --error-log errors.logHow the file runs
Section titled “How the file runs”The file streams through the statement splitter, which handles DELIMITER, dollar quoting and
comments, so multi-gigabyte dumps run in flat memory. Result rows are discarded; to see them, use
querybara query with -f. Statements run as the file says, its own BEGIN and
COMMIT included. The encoding is detected unless you pass --encoding.
--error-log writes each failed statement with its error to a file.
Safety
Section titled “Safety”The same rules as querybara query apply: risky statements and, on
production profiles, every write need a confirmation or --yes. Read-only targets refuse writes,
and so does --read-only.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Every statement ran |
| 1 | Some statements failed with --continue |
| 2 | Stopped at a failure, or another error |
| 130 | Interrupted |
Related
Section titled “Related”Documents Querybara 0.1.1 · built frombc9f5aa