Python_Institute
PCPP-32-101 · Question #87
What is the result of the following code assuming that the SELECT query returns three records?
The correct answer is A. An empty list. Calling fetchall() twice consecutively without re-executing the query returns an empty list the second time, because the cursor's result set has already been exhausted after the first fetchall()
Databases
Question
What is the result of the following code assuming that the SELECT query returns three records?
Exhibit
Options
- AAn empty list.
- BAn exception will be raised.
- CA list of three records in the form of tuples.
- DNone
How the community answered
(35 responses)- A71% (25)
- B17% (6)
- C3% (1)
- D9% (3)
Explanation
Calling fetchall() twice consecutively without re-executing the query returns an empty list the second time, because the cursor's result set has already been exhausted after the first fetchall()
Topics
#sqlite3#fetchall#cursor#empty result set
Community Discussion
No community discussion yet for this question.
