I am learning python and trying to use it to create a PDF report based on the results of a query from MySQL database. This is the part of coding I am having trouble with
qry = "SELECT <irrelevant>"
cursor.execute(qry)
result = cursor.fetchone()
if result is not None:
result = cursor.fetchall()
numrows = cursor.rowcount
return result, numrows
This should have yielded 3 results, as shown in the screenshot when the SQL query was run directly on the database as shown in screenshot 1.
However, when the python script is run it only retrieves two rows as shown below.
Interestingly, the cursor.rowcount returns 3 although only two records are shown. I would love to know what I am doing wrong. Thank you.