예제 #1
0
    def set_aggregate_val(self, home_country: Countries, away_country: Countries, new_val):
        """Sets the aggregate value for the specified directed country pair"""
        # statement = "UPDATE " + self._agg_table_name + " SET `title_sentiment`=" + new_val + " WHERE `from`=" + home_country.get_iso_code() + " AND `to`=" + away_country.get_iso_code()
        self._cursor.execute("UPDATE " + self._agg_table_name + " SET `title_sentiment`=%s WHERE `from`=%s AND `to`=%s",
                             (new_val, home_country.get_iso_code(), away_country.get_iso_code()))

        # self._cursor.execute(statement)
        self._db.commit()
예제 #2
0
    def get_aggregate_val(self, home_country: Countries, away_country: Countries):
        statement = "SELECT * FROM " + self._agg_table_name + " WHERE `from`='" + home_country.get_iso_code() + "' AND `to`='" + away_country.get_iso_code() + "'"

        self._cursor.execute(statement)
        result = self._cursor.fetchall()
        if len(result) == 1:
            return result[0]
        return None
예제 #3
0
 def _get_directed_table_name(self, home_country: Countries, away_country: Countries):
     return "{}_to_{}".format(home_country.get_iso_code(), away_country.get_iso_code())