単刀直入に。
コード
import MySQLdb #localhostのMysqlへと接続 connection = MySQLdb.connect(db="データベース名",user="root or 指定したユーザー名") cs = connection.cursor() #sqlの検索結果を得る cs.execute("SELECT COUNT(*) FROM tablename WHERE condition ") result = cs.fetchall() print result