Example #1
0
 def __init__(self, quote, database, logger=None):
     if logger == None:
         logSys = LogSubSystem(__name__, "debug")
         self._logger = logSys.getLog()
     else:
         self._logger = logger
     self.connection = sql.connect(database)
     with self.connection:
         self.connection.row_factory = sql.Row
         self.cursor = self.connection.cursor()
         self.cursor.execute(
             'select symbol, market, rss from stocks where ticker=:ticker',
             {"ticker": quote})
         row = self.cursor.fetchone()
         if (row == None):
             self._logger.error(
                 '** No reference found in database, exiting...')
             sys.exit(-1)
         else:
             self.symbol = row['symbol']
             self.market = row['market']
             self.rss_source = row['rss']
             self.rss = 'http://www.google.com/finance/company_news?q=' + row[
                 'market'] + ':' + row['symbol'] + '&output=rss'
     self.name = quote
    def __init__(self, quotes, db_name, logger=None):
        # Logger initialisation
        if logger == None:
            self._logger = LogSubSystem('QuoteDL', "debug").getLog()
        else:
            self._logger = logger

        # Getting quotes info from db
        try:
            #self._db = DatabaseSubSystem(db_name, self._logger)
            #tables = self._db.getTables()  #TODO:Check table presence and error handling
            #res = self._db.execute('select symbol, market, rss from stocks where ticker=:ticker', {"ticker": quotes})

            self.symbol = res['symbol']
            self.market = res['market']
            self.rss_source = res['rss']
            self.rss = 'http://www.google.com/finance/company_news?q=' + self.market + ':' + self.symbol + '&output=rss'
        except:
            self._logger.error('Using database SubSystem')
            self._db.close()
        self.name = quotes