Use cursor as ctx mgr