Add a generator to MysqlRedFam to retrieve redfams from db by status
This commit is contained in:
17
mysqlred.py
17
mysqlred.py
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user