code: def wrap_conn(conn_func):
      
      def call(*args, **kwargs):
          try:
              conn = conn_func(*args, **kwargs)
              cursor_func = getattr(conn, CURSOR_WRAP_METHOD)
              wrapped = wrap_cursor(cursor_func)
              setattr(conn, cursor_func.__name__, wrapped)
              return conn
          except Exception:  # pragma: NO COVER
              logging.warning('Fail to wrap conn, mysql not traced.')
              return conn_func(*args, **kwargs)
      return call
docs: Wrap the mysql conn object with TraceConnection.