code: def build_query_cmd(self, query, csv=False):
          
          _cmd = "su postgres -c %s"
          if not csv:
              _dbcmd = "psql foreman -c %s"
          else:
              _dbcmd = "psql foreman -A -F , -X -c %s"
          dbq = _dbcmd % quote(query)
          return _cmd % quote(dbq)
docs: Builds the command needed to invoke the pgsql query as the postgres
          user.
          The query requires significant quoting work to satisfy both the
          shell and postgres parsing requirements. Note that this will generate
          a large amount of quoting in sos logs referencing the command being run