Add a generator to MysqlRedFam to retrieve redfams from db by status

This commit is contained in:
2015-09-19 19:50:38 +02:00
parent 8059bb9992
commit dbcfe8f106

View File

@@ -264,3 +264,20 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
type( self )._cached_update_data.append( ( red_page_id, heading, type( self )._cached_update_data.append( ( red_page_id, heading,
beginning, ending, status, beginning, ending, status,
self.__fam_hash ) ) 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