Skip to content

Command line parameters

O2eg edited this page Apr 17, 2022 · 12 revisions

About usage modes read here.

In all deployment modes, two parameters are mandatory: --packet-name and --db-name.

Ways to list target databases:

--db-name=my_db_01	# deployment on the specified database only
--db-name=my_db_01,my_db_02	# deployment on the listed databases
--db-name=my_db_0*	# deployment on databases matching mask
--db-name=ALL		# deployment will be carried out on all databases specified in the [databases] section of db_converter.conf file
--db-name=ALL,exclude:my_db_01,my_db_02		# deployment on all databases except those listed after ",exclude:"
--db-name=ALL,exclude:my_db_0*			# deployment on all databases except those matching the mask "my_db_0*"
--db-name=ALL,exclude:my_db_0*,my_db_10		# deployment on all databases except those matching the mask "my_db_0*" and except "my_db_10"

By default, the conversion is performed in parallel (asynchronous) mode on all specified databases. In some cases, sequential execution in the specified order is required. To do this, use the --seq key.

Deployment options:

  • --seq - sequential execution in order listed in db_converter.conf
  • --force - ignore the difference between packet hashes. If the first execution of packet was completed with an error not related to the connection and this packet was modified during the next launch, then execution requires confirmation without --force option
  • --skip-step-cancel - skip the whole step on first error like Deadlock, QueryCanceledError
  • --skip-action-cancel - skip action errors like Deadlock, QueryCanceledError
  • --conf - override parameters of conf/db_converter.conf. JSON format.
  • --placeholders - replace placeholders in SQL code with the specified values. JSON format.

Additional options that can be used with --db-name and --packet-name (one of the following):

  • --status - get the status of the packet for a specified database (possible statuses: done, started, exception, new)
  • --wipe - delete information about --packet-name from action tracker (dbc_* tables)
  • --stop - execute pg_terminate_backend for all db_converter's connections with specific packet name
  • --list - list all databases according --db-name mask
  • --unlock - unlock the specified packet (delete row from dbc_locks table)

Extended options:

  • --template - copy *.sql files from packets/templates/template to packets/packet-name
  • --version - show version of db_converter

The types of errors, which is affected by parameters --skip-*-errors:

Exception name Code Description
QueryCanceledError 57014 Class 57 - Operator Intervention
AdminShutdownError 57P01 Class 57
CrashShutdownError 57P02 Class 57
ServerNotReadyError 57P03 Class 57
DeadlockError 40P01 Class 40 - Transaction Rollback

If --skip-*-errors are not specified, then a re-transaction will be performed for the above exceptions after conn_exception_sleep_interval seconds. All other types of exceptions will cause the packet deployment to complete, with a traceback is written to the dbc_steps.exception_descr table.

Overriding parameters

The parameters of db_converter.conf can be overridden via the command line using the --conf key, for example:

python38 db_converter.py \
	--packet-name=dba_get_conf \
	--db-name=dbc \
        --conf="{'execute_sql':'False','cancel_wait_tx_timeout':'1 minutes'}"

Note: json object keys and values must be enclosed in single quotes. Parameter values with quotation marks (from db_converter.conf) must be specified in the command line without quotation marks (for example, cancel_wait_tx_timeout).

Clone this wiki locally