200k views
5 votes
Which MySQLCursor object returns all the rows in a result set?

a

fetchone()

b

fecthsome()

c

fetchmany()

d

fetchall()

User Dgw
by
5.7k points

1 Answer

2 votes

Answer:

fetchall()

Step-by-step explanation:

MySQLCursor object method fetchall() method returns all the rows in the resultset.

For example:

>>> cursor.execute("SELECT * FROM Student ORDER BY rollno")

>>> rows = cursor.fetchall()

Now rows will contain a reference to the results of the query. If the size of the resultset returned by the query is 0 then rows will reference an empty set.

fetchmany() and fetchone() are , on the other hand , used to retrieve many(count specified) or one row from the result respectively.

User Crizly
by
6.4k points