0
sqlstr = 'SELECT email, count FROM Counts ORDER BY count DESC LIMIT 10'

for row in cur.execute(sqlstr):
    print(str(row[0]), row[1])   
   

print(str(cur.execute(sqlstr))) #2this prints sqlite3.Cursor object at 0x0000018B702960C0

i'm having trouble with understanding what kind of data structure sqlstr query returns in python. py prints fine when iterating through the query return, but prints it as an object outside the iteration. what is happening during runtime cur.execute(sqlstr). is there a way to dump the contents of the cursor object? is there a way to see the contents of the cursor object in ide(using visual studio code)?

Emre
  • 1
  • See https://stackoverflow.com/questions/192109/is-there-a-built-in-function-to-print-all-the-current-properties-and-values-of-a – Nick Sep 12 '22 at 23:54
  • cur.execute(sqlstr).fetchall() kind of does the job. however i still can't understand how the iteration dissolves the cursor object into a printable data structure. – Emre Sep 13 '22 at 01:32
  • 1
    This explains how an iterator works... https://stackoverflow.com/questions/19151/how-to-build-a-basic-iterator – Nick Sep 13 '22 at 01:33

0 Answers0