returning results of sql select count

This is the place for queries that don't fit in any of the other categories.

returning results of sql select count

Postby droidus » Wed Apr 02, 2014 12:32 am

I am returning results of a sql query:
Code: Select all
cursor = cnx.cursor()
cursor.execute("SELECT COUNT(*) from members where username!='sandy'")

When this is executed, I get (2,). I would expect 2. Why did it return it in this format?
Posts: 1
Joined: Mon Mar 31, 2014 1:49 pm

Re: returning results of sql select count

Postby stranac » Wed Apr 02, 2014 8:34 am

The fetch* methods always return selected rows as tuples, or None if there are no results.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
Posts: 1790
Joined: Thu Feb 07, 2013 3:42 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests