def ExportingCursorWrapper(cursor_class, alias, vendor):
class CursorWrapper(cursor_class):<EOL><INDENT>"""<STR_LIT>"""<EOL>def execute(self, *args, **kwargs):<EOL><INDENT>execute_total.labels(alias, vendor).inc()<EOL>with ExceptionCounterByType(errors_total, extra_labels={<EOL>'<STR_LIT>': alias, '<STR_LIT>': vendor}):<EOL><INDENT>return super(CursorWrapper, self).execute(*args, **kwargs)<EOL><DEDENT><DEDENT>def executemany(self, query, param_list, *args, **kwargs):<EOL><INDENT>execute_total.labels(alias, vendor).inc(len(param_list))<EOL>execute_many_total.labels(alias, vendor).inc(len(param_list))<EOL>with ExceptionCounterByType(errors_total, extra_labels={<EOL>'<STR_LIT>': alias, '<STR_LIT>': vendor}):<EOL><INDENT>return super(CursorWrapper, self).executemany(<EOL>query, param_list, *args, **kwargs)<EOL><DEDENT><DEDENT><DEDENT>return CursorWrapper<EOL>
Returns a CursorWrapper class that knows its database's alias and
    vendor name.