def execute(connection: connection, statement: str) -> Optional[List[Tuple[str, ...]]]:
response = list()  <EOL>with connection:<EOL><INDENT>with connection.cursor(cursor_factory=Psycopg2Cursor) as cursor:<EOL><INDENT>cursor.execute(statement)<EOL>connection.commit()<EOL>try:<EOL><INDENT>response = cursor.fetchall()<EOL>if not response:<EOL><INDENT>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>return None<EOL><DEDENT><DEDENT>except ProgrammingError as e:<EOL><INDENT>if e.args and e.args[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>return None<EOL><DEDENT>raise e<EOL><DEDENT>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>for line in response:<EOL><INDENT>log(str(line), logger_name=_LOGGER_NAME)<EOL><DEDENT><DEDENT><DEDENT>return response<EOL>
Execute PGSQL statement and fetches the statement response.

    Parameters
    ----------
    connection: psycopg2.extensions.connection
        Active connection to a PostGreSQL database.
    statement: str
        PGSQL statement to run against the database.

    Returns
    -------
    response: list or None
        List of tuples, where each tuple represents a formatted line of response from the database engine, where
        each tuple item roughly corresponds to a column. For instance, while a raw SELECT response might include
        the table headers, psycopg2 returns only the rows that matched. If no response was given, None is returned.