Пример #1
0
    def write(self):
        """update the index information in the SQL database"""
        tbl = 'stockindex_app_index'
        index = SqlConnection(tbl)
        values_list = [x for x in self.df.T.to_dict().values()]

        for value in values_list:
            stmt = update(index.table).values(
                current_value=value['current_value'],
                prior_close_value=value['prior_close_value'],
                change_value=value['change_value'],
                high_value=value['high_value'],
                low_value=value['low_value'],
                high_value_52_weeks=value['high_value_52_weeks'],
                low_value_52_weeks=value['low_value_52_weeks'],
            ).where(
                index.table.c.id == value['id']
            )
            index.update_query(stmt)
Пример #2
0
    def write(self):
        """update the stock information in the SQL database"""
        tbl = 'stockindex_app_stock'
        stock = SqlConnection(tbl)
        values_list = [x for x in self.df.T.to_dict().values()]

        for value in values_list:
            stmt = update(stock.table).values(
                current_price=value['current_price'],
                prior_close_price=value['prior_close_price'],
                change_price=value['change_price'],
                market_cap=value['market_cap'],
                high_market_cap=value['high_market_cap'],
                low_market_cap=value['low_market_cap'],
                high_price=value['high_price'],
                low_price=value['low_price'],
                high_price_52_weeks=value['high_price_52_weeks'],
                low_price_52_weeks=value['low_price_52_weeks'],
                shares_outstanding=value['shares_outstanding']
            ).where(
                stock.table.c.id == value['id']
            )
            stock.update_query(stmt)