python - Get row count in MySQLdb -


is there better way row count doing following?

cursor.execute("select distinct(provider_id) main_iteminstance") num_items = len(cursor.fetchall()) 

is there shorthand in mysqldb above?

you execute following sql directly on cursor.execute rather depending on mysqldb:

cursor.execute("select count(distinct provider_id) main_iteminstance") 

then result query.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -