Add new generator-method to fetch RedFams by Status and Ending
Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=26 FS#26]
This commit is contained in:
@@ -246,6 +246,7 @@ class MysqlRedFam( MysqlRed ):
|
|||||||
_update_query = 'UPDATE `{prefix}_red_families` \
|
_update_query = 'UPDATE `{prefix}_red_families` \
|
||||||
SET `red_page_id` = ?, `heading` = ?, `beginning` = ?, `ending` = ?, \
|
SET `red_page_id` = ?, `heading` = ?, `beginning` = ?, `ending` = ?, \
|
||||||
`status`= ? WHERE `fam_hash` = ?;'
|
`status`= ? WHERE `fam_hash` = ?;'
|
||||||
|
|
||||||
_cached_insert_data = {}
|
_cached_insert_data = {}
|
||||||
_insert_query = 'INSERT INTO `{prefix}_red_families` \
|
_insert_query = 'INSERT INTO `{prefix}_red_families` \
|
||||||
( fam_hash, red_page_id, beginning, ending, status, heading, \
|
( fam_hash, red_page_id, beginning, ending, status, heading, \
|
||||||
@@ -259,9 +260,6 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
|
|||||||
|
|
||||||
super().__init__( )
|
super().__init__( )
|
||||||
|
|
||||||
def __del__( self ):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_fam( self, fam_hash ):
|
def get_fam( self, fam_hash ):
|
||||||
"""
|
"""
|
||||||
Retrieves a red family row from MySQL-Database for given fam_hash
|
Retrieves a red family row from MySQL-Database for given fam_hash
|
||||||
@@ -335,6 +333,25 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
|
|||||||
for row in res:
|
for row in res:
|
||||||
yield row
|
yield row
|
||||||
|
|
||||||
|
def get_by_status_and_ending( self, status, ending ):
|
||||||
|
"""
|
||||||
|
Generator witch fetches redFams with given status from DB
|
||||||
|
"""
|
||||||
|
|
||||||
|
cursor = type( self ).connection.cursor( mysqldb.DictCursor )
|
||||||
|
|
||||||
|
cursor.execute(
|
||||||
|
'SELECT * FROM `{prefix}_red_families` WHERE `status` = ? AND'.
|
||||||
|
format(prefix=type( self ).db_table_prefix) +
|
||||||
|
'`ending` >= ?;', ( status, ending ) )
|
||||||
|
|
||||||
|
while True:
|
||||||
|
res = cursor.fetchmany( 1000 )
|
||||||
|
if not res:
|
||||||
|
break
|
||||||
|
for row in res:
|
||||||
|
yield row
|
||||||
|
|
||||||
|
|
||||||
class MysqlRedError(Exception):
|
class MysqlRedError(Exception):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user