db-patch

Man page

db-patch

SYNOPSIS

db-patch [options]

DESCRIPTION

This program execute static and dinamic SQL patches in several databases. Besides the tool store the SQL executed in each database.

  • The static patches are files that contain SQL sentences. Note that a SQL sentence can have several lines and must end with ‘;’.
  • The dinamic patches are python files that can interact with the database and generate/execute SQL code dinamically.

By default the program uses ODBC for connect with the databases, and therefore the /etc/odbcinst.ini must be correctly configured. However, it also suports native connections. For this purpose it is necessary install the db-patch-yourDbEngine-native package or provide your implementation using the option –connection-plugins.

Note that it is possible to define and customize patches and ODBC connectors through plugins (using the options –patch-plugins and –odbc-plugins).

OPTIONS

-h, –help
Show the help message and exit

Database options

-u DB_USER, –db-user=DB_USER
Database user. Mandatory
-p DB_PASS, –db-pass=DB_PASS
Database password. Mandatory
-H DB_HOST, –db-host=DB_HOST
Database host. By default “localhost”
-P DB_PORT, –db-port=DB_PORT
Database port
-E DB_ENGINE, –db-engine=DB_ENGINE
Database engine (MySQL, PostgreSQL, etc). Mandatory
-C DB_CHARSET, –db-charset=DB_CHARSET
The charset used for database connections. By default: ascii
-s DB_SOCKET, –db-socket=DB_SOCKET
Database Unix socket
-e EXCLUDE, –exclude=EXCLUDE
Regular expression for exclude databases. Mandatory to use python regular expressions (re module). Example: -e “a[a-z]+”
-i INCLUDE, –include=INCLUDE
Regular expression for include databases. See python re module
-d DATABASES, –databases=DATABASES
List of databases to patch.Examples: -d W24_WE1 or -d W24_WE1,W24_WH6
–db-charset-policy=DB_CHARSET_POLICY
The policy to apply when the charset can not full replace strings. Posible values: [ignore|replace|xmlcharrefreplace]. By default: ignore

Patch options

-f PATCH_FILE, –file=PATCH_FILE
File that contains the patch. The patch executor uses the extension for runs each patch. For the ”.sql” patches the mydb keyword will be replaced by each database name. Mandatory
–patch-plugins=PATCH_PLUGINS
Extra path for locate customized patchs. By default: ~/.dbpatch/patch
–patch-type=PATCH_TYPE
Patch type. Supported: sql, python. Extensible via patch plugins (see –patch-plugins).By default the patch type will be determined by the file extension

Connection and ODBC options

–odbc-driver=ODBC_DRIVER
Define the ODBC driver to use. It must be defined in the odbcinst.ini
–odbc-dsn=ODBC_DSN
Define a DSN for ODBC connections
–odbc-extra=ODBC_EXTRA
Provide extra options for make the ODBC connection string
–odbc-full-connection=ODBC_FULL_CONN
Define the full ODBC connection string
–odbc-inst-ini=ODBC_INSTINI
Full path to odbcinst.ini. By default: /etc/odbcinst.ini
-N, –native
Use a native driver for database connection. By default uses ODBC (requires to configure the odbcinst.ini file)
–odbc-plugins=ODBC_PLUGINS
Define the ODBC query builder path for locate custom ODBC connections. By default: ~/.dbpatch/odbc
–connection-plugins=CONNECTION_PLUGINS
Extra path for locate custom native connections. By default: ~/.dbpatch/connection

SQL tracing options

-c, –clean
Avoid that all the SQL executed will be stored
–gen-dir=GENERATED_DIR
Directory where the SQL sentences for each patch will be stored. By default: sql_sentences
–gen-file=GEN_FILE
Determines the name of the file where the generated SQL is stored.The “HOST” flag will be replaced by the hostname.The “NAME” flag will be replaced by the patch name without extension.The “TIME” flag will be replaced by a timestamp. By default: “HOST_NAME_TIME.sql”
-S, –show-sql
Show the generated SQL sentences in the output

Run options

-t, –dry-run
Generate all the SQL sentences without modify the database
-v, –verbose
Increase the verbose level
–pre-cmd=PRE_CMD
Command to be executed before of execute the patch. By example –pre-cmd ‘find -name “*.pyc” -delete’
–post-cmd=POST_CMD
Command to be executed after of execute the patch. By example –post-cmd ‘tar -czf applied.tgz sql_generated/; rm -rf sql_generated/’

Extra options

–extra-opts=EXTRA_OPTS
Allow use a configuration file for introduce new options. The options will be stored as “section_name.option_name”
–args-file=ARGS_FILE
Allow use a file for introduce the arguments. The command line options will overwrite the options defined in the file

See

Configuration files:

/etc/odbcinst.ini
For define drivers
/etc/odbc.ini
For define DSN connections

Author

Miguel A. Martinez Pinedo <miguel.mpinedo@gmail.com>

Wrote this manpage for the Debian system.

Table Of Contents

Previous topic

Developer guide

Next topic

db-patch-history

This Page