nerdexam
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

PCPP-32-101 question #87 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)
  • A
    71% (25)
  • B
    17% (6)
  • C
    3% (1)
  • D
    9% (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.

Full PCPP-32-101 Practice