diff --git a/mysqlred.py b/mysqlred.py index ea964d4..cb9754d 100644 --- a/mysqlred.py +++ b/mysqlred.py @@ -264,3 +264,20 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );' type( self )._cached_update_data.append( ( red_page_id, heading, beginning, ending, status, self.__fam_hash ) ) + + def get_by_status( self, status ): + """ + Generator witch fetches redFams with given status from DB + """ + + cursor = type( self ).connection.cursor( mysqldb.DictCursor ) + + cursor.execute( 'SELECT * FROM `red_families` WHERE `status` = ?;', + ( status, ) ) + + while True: + res = cursor.fetchmany( 1000 ) + if not res: + break + for row in res: + yield row