man(8)

NAME
engine-db-query - A tool to query engine database.

SYNOPSIS
engine-db-query [-h] [-j] [-c] [-d DATABASE] [-i ID_JSON]
                     [-m JSON_DESCRIPTION] [-t JSON_TYPE] [-l JSON_NAME]
                     [-o PORT] [-u USERNAME] [-k KB_URL] [-b BUG_URL]
                     [-p PASSWORD] [-f FQDN] -s STATEMENT

DESCRIPTION
The engine-db-query is a tool and python module to query engine database. The argument can be a pure SQL query statement or SQL file.
It is posible also control the output format, like CSV, JSON or python array dict (default).
Running engine-db-query in Engine machine will grab the credentials from /etc/ovirt-engine/engine.conf.d/10-setup-database.conf
but it is possible to overwrite with the --username, --fqdn and --password.

--fqdn
    Engine FQDN or IP Address

--username
    PostgreSQL username (default: engine)

--password
    PostgreSQL password

--port
    PostgreSQL port (default: 5432)

--database
    PostgreSQL database (default: engine)

--statement
    SQL statement or SQL file

--json
    Return a JSON output

--json-name
    Add a name to json output (See examples session below)

--json-id
    Add an identifier id to the JSON output, often used /etc/machine-id

--json-type
    Add a type to JSON output, often used WARNING, ERROR, DEBUG, INFO

--json-description
    Add a description to JSON output

--json-bugzilla
    Add a bugzilla url to JSON output

--json-knowledge-base
    Add a knowledge base url to JSON output

--csv
    Return CSV output

--log
    Specify the path for the log filename (if not specificed, stdout/stderr are available)

EXAMPLES
1) JSON output (Engine Host)
# engine-db-query --statement "SELECT * FROM cluster" \
                  --json --log /tmp/engine-db-query.log
2) CSV output (Engine Host)
# engine-db-query --statement "SELECT * FROM cluster" \
                  --csv 3) JSON output (Remote Host)
# engine-db-query --username engine \
                  --password superpass123 \
                  --fqdn MY_ENGINE_FQDN \
                  --statement "SELECT * FROM cluster" \
                  --json 4) JSON output (Remote Host)
# engine-db-query --username engine \
                  --password superpass123 \
                  --fqdn MY_ENGINE_FQDN \
                  --statement "SELECT * FROM cluster" \
                  --json 5) JSON output, adding name Clusters (Remote host)
# engine-db-query --username engine \
                  --password superpass123 \
                  --fqdn MY_ENGINE_FQDN \
                  --statement "SELECT * FROM cluster" \
                  --json \
                  --json-name "Clusters" Returns:
{
    "name": "check_windows_with_incorrect_timezone",
        ...
    "Clusters": [
        [{
            "ha_reservation": false,
            "hosts_with_broken_connectivity_threshold": 50,
        ...
6) CSV output (Remote Host)
# engine-db-query --username engine \
                  --password superpass123 \
                  --fqdn MY_ENGINE_FQDN \
                  --statement "SELECT * FROM cluster" \
                  --csv 7) Statement as a file (Remote Host)
# engine-db-query --username engine \
                  --password superpass123 \
                  --fqdn MY_ENGINE_FQDN \
                  --statement my-file.sql

BUGS
Report bugs to <http://bugzilla.redhat.com>

COPYRIGHT
Copyright 2018 Red Hat, Inc.