Python/SQL - How the cursor functions -


in code have function needs return either string or none depending on present in database. @ moment result list string answer inside, or none. there change made result in string or none being returned, rather having index list?

here code:

def retrieve_player_name(username):     param = [(username)]     command = ("""                 select username players                 username = ?                 """)     result = cur.execute(command, param).fetchone()     if result not none:         return result[0] 

thanks in advance.

a database cursors fetches entire rows, not values. row single value inside still row.

if don't want write row[0] multiple times, create helper function execute_and_return_a_single_value_from_query().


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -