MCPcopy Create free account
hub / github.com/PyMySQL/mysqlclient / scroll

Method scroll

src/MySQLdb/cursors.py:398–414  ·  view source on GitHub ↗

Scroll the cursor in the result set to a new position according to mode. If mode is 'relative' (default), value is taken as offset to the current position in the result set, if set to 'absolute', value states an absolute target position.

(self, value, mode="relative")

Source from the content-addressed store, hash-verified

396 return result
397
398 def scroll(self, value, mode="relative"):
399 """Scroll the cursor in the result set to a new position according
400 to mode.
401
402 If mode is 'relative' (default), value is taken as offset to
403 the current position in the result set, if set to 'absolute',
404 value states an absolute target position."""
405 self._check_executed()
406 if mode == "relative":
407 r = self.rownumber + value
408 elif mode == "absolute":
409 r = value
410 else:
411 raise ProgrammingError("unknown scroll mode %s" % repr(mode))
412 if r < 0 or r >= len(self._rows):
413 raise IndexError("out of range")
414 self.rownumber = r
415
416 def __iter__(self):
417 self._check_executed()

Callers

nothing calls this directly

Calls 2

ProgrammingErrorClass · 0.85
_check_executedMethod · 0.80

Tested by

no test coverage detected