<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fetch_events(cursor, config, account_name):
 """Generator that returns the events"""

    query = config['indexer'].get('query',
        'select * from events where user_agent glob \'*CloudCustodian*\'')

    for event in cursor.execute(query):
        event['account'] = account_name
        event['_index'] = config['indexer']['idx_name']
        event['_type'] = config['indexer'].get('idx_type', 'traildb')
        yield event