diff --git a/mysqlred.py b/mysqlred.py index 1a782b8..ea964d4 100644 --- a/mysqlred.py +++ b/mysqlred.py @@ -203,38 +203,30 @@ SET `red_page_id` = ?, `heading` = ?, `beginning` = ?, `ending` = ?, \ article0, article1, article2, article3, article4, article5, article6, \ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );' - def __init__( self, fam_hash ): + def __init__( self ): """ Creates a new instance, runs __init__ of parent class """ super().__init__( ) - - self.__fam_hash = fam_hash - - self.data = self.get_fam() def __del__( self ): pass - def get_fam( self ): + def get_fam( self, fam_hash ): """ Retrieves a red family row from MySQL-Database for given fam_hash @returns dict Dictionairy with data for given fam hash False if none found """ + self.__fam_hash = fam_hash cursor = type( self ).connection.cursor( mysqldb.DictCursor ) cursor.execute( 'SELECT * FROM `red_families` WHERE `fam_hash` = ?;', - ( self.__fam_hash, ) ) - res = cursor.fetchone() - - if res: - return res - else: - return False + ( fam_hash, ) ) + self.data = cursor.fetchone() def add_fam( self, articlesList, heading, red_page_id, beginning, ending=None, status=0 ): diff --git a/redfam.py b/redfam.py index 3b4581b..ba33d1e 100644 --- a/redfam.py +++ b/redfam.py @@ -191,7 +191,8 @@ class RedFamParser( RedFam ): """ # We need a connection to our mysqldb - self.__mysql = MysqlRedFam( self._fam_hash ) + self.__mysql = MysqlRedFam( ) + self.__mysql.get_fam( self._fam_hash ) if not self.__mysql.data: self.__mysql.add_fam( self._articlesList, self._heading,