Beispiel #1
0
    def _update_data_for_date(self, date, partial):
        """
        Uses lpoWeb module to retrieve data for specified date
        and inserts into new DB entry
        NOTE - use partial parameter to specify if entry already exists
        """
        # clear out any partial data for this entry
        if partial:
            self.db.execute('DELETE FROM {} WHERE Date={}'.format(
                self.table, date.strftime('%Y%m%d')))
            self.db.commit()

        try:
            data = lpoWeb.get_data_for_date(date)
        except:
            raise

        for entry in data:
            self.db.execute(
                '''INSERT INTO {} (Date, Time, Status, Air_Temp, Barometric_Press, Wind_Speed)
                                VALUES (?, ?, ?, ?, ?, ?)'''.format(
                    self.table),
                (entry['Date'].replace("_", ""), entry['Time'],
                 entry['Status'], entry['Air_Temp'], entry['Barometric_Press'],
                 entry['Wind_Speed']))
        self.db.commit()
Beispiel #2
0
 def _update_data_for_date(self, date, partial):
     """
     Uses lpoWeb module to retrieve data for specified date
     and inserts into new DB entry
     NOTE - use partial parameter to specify if entry already exists
     """        
     # clear out any partial data for this entry
     if partial:
         self.db.execute('DELETE FROM {} WHERE Date={}'.format(self.table, date.strftime('%Y%m%d')))
         self.db.commit()
     
     try:
         data = lpoWeb.get_data_for_date(date)
     except:
         raise
     
     for entry in data:
         self.db.execute('''INSERT INTO {} (Date, Time, Status, Air_Temp, Barometric_Press, Wind_Speed)
                             VALUES (?, ?, ?, ?, ?, ?)'''.format(self.table), (entry['Date'].replace("_", ""),
                                                                                entry['Time'],
                                                                                entry['Status'],
                                                                                entry['Air_Temp'],
                                                                                entry['Barometric_Press'],
                                                                                entry['Wind_Speed']))
     self.db.commit()