MCPcopy Index your code
hub / github.com/PyMySQL/mysqlclient / test_cursor_discard_result

Function test_cursor_discard_result

tests/test_cursor.py:193–224  ·  view source on GitHub ↗
(Cursor)

Source from the content-addressed store, hash-verified

191# Test that cursor can be used without reading whole resultset.
192@pytest.mark.parametrize("Cursor", [MySQLdb.cursors.Cursor, MySQLdb.cursors.SSCursor])
193def test_cursor_discard_result(Cursor):
194 conn = connect()
195 cursor = conn.cursor(Cursor)
196
197 cursor.execute(
198 """\
199CREATE TABLE test_cursor_discard_result (
200 id INTEGER PRIMARY KEY AUTO_INCREMENT,
201 data VARCHAR(100)
202)"""
203 )
204 _tables.append("test_cursor_discard_result")
205
206 cursor.executemany(
207 "INSERT INTO test_cursor_discard_result (id, data) VALUES (%s, %s)",
208 [(i, f"row {i}") for i in range(1, 101)],
209 )
210
211 cursor.execute(
212 """\
213SELECT * FROM test_cursor_discard_result WHERE id <= 10;
214SELECT * FROM test_cursor_discard_result WHERE id BETWEEN 11 AND 20;
215SELECT * FROM test_cursor_discard_result WHERE id BETWEEN 21 AND 30;
216"""
217 )
218 cursor.nextset()
219 assert cursor.fetchone() == (11, "row 11")
220
221 cursor.execute(
222 "SELECT * FROM test_cursor_discard_result WHERE id BETWEEN 31 AND 40"
223 )
224 assert cursor.fetchone() == (31, "row 31")
225
226
227def test_binary_prefix():

Callers

nothing calls this directly

Calls 6

cursorMethod · 0.80
executeMethod · 0.80
executemanyMethod · 0.80
nextsetMethod · 0.80
connectFunction · 0.70
fetchoneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…