Open a connection, commit a transaction, and close it.

def execute_closing_transaction(statements: Iterable):
    """Open a connection, commit a transaction, and close it."""

    with closing(connect()) as conn:
        with conn.cursor() as cursor:
            for statement in statements:
                cursor.execute(statement)