#NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# cursor = connection . cursor ( ) #NEWLINE# cursor . execute ( '\n        select \n            artist_id,\n            count(*)\n        from\n            playlist_playlistprofile_fanof_artists\n        group by artist_id\n        order by count desc\n        ' ) #NEWLINE# i = 1 #NEWLINE# for row in cursor . fetchall ( ) : #NEWLINE# #INDENT# Artist . objects . filter ( pk = row [ 0 ] ) . update ( rank = i ) #NEWLINE# i += 1