From dbcfe8f1067335725d9897f01619ed22038e0f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sat, 19 Sep 2015 19:50:38 +0200 Subject: [PATCH] Add a generator to MysqlRedFam to retrieve redfams from db by status --- mysqlred.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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