'python len from SQL query returning differing int values

I have a simple sqlite query set up to use parameters from a html form that I reference. When I run this Flask web app and pass through a username that already exists in my database, I get two different values for the len function dependent on whether or not I assign this function to a variable.

username_match = db.execute('SELECT userid FROM users WHERE userid = ?', (request.form.get('username'),))

match = len(username_match.fetchall())
    
print(match)
print(len(username_match.fetchall()))
    

The print(match) returns a 1 when a matching username is queried, but for some reason print(len(username_match.fetchall())) returns a value of 0 for the same username query.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source