Skip to content

querybara ddl

  • CLI
  • PostgreSQL
  • MySQL
  • MariaDB

querybara ddl reads the structure of a database and prints it as a DDL script, in dependency order, ready to create the objects in an empty database. It writes no data and changes nothing. Use it to keep the schema in version control or to review what a database contains.

querybara ddl --help
Usage: querybara ddl [options] <target>
print the schema as a DDL script in dependency order
Arguments:
target profile name or id, or connection URI
Options:
--schema <name> PostgreSQL schema to dump; repeatable (default: all)
--database <name> database to dump
--out <file> write the script to a file instead of stdout
--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 --tls and SSH options are described in Global options.

Print the whole structure:

Terminal window
querybara ddl shop-prod

Write one PostgreSQL schema to a file:

Terminal window
querybara ddl "postgres://[email protected]/shop" --schema shop --out shop-schema.sql

Dump another database on the same MySQL server:

Terminal window
querybara ddl "mysql://[email protected]/shop" --database shop_eu --out shop_eu.sql
  • On PostgreSQL, --schema limits the script to the schemas you name; by default it covers every schema other than the system schemas. MySQL and MariaDB dump the connected database, and warn if you pass --schema.
  • The script starts with a comment line naming the target, the engine, the server version and the database.

Documents Querybara 0.1.1 · built frombc9f5aa