예제 #1
0
 def test_open(self):
     print('WeatherDBTest - test_open')
     db_name = 'test/test_weather_data.db'
     mydb = weather_utils.WeatherDB(db_name)
     sql = "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='station'";
     mydb.cursor.execute(sql)
     self.assertTrue(mydb.cursor.fetchone())
     mydb.close()
예제 #2
0
ii = 0
for itt in tlst:
    if ii > 0:
        ttpl = ttpl + (int(tlst[ii]), )
    ii += 1

glst = gtpl_raw.split(',')
gtpl = (int(glst[0]), )
ii = 0
for igt in glst:
    if ii > 0:
        gtpl = gtpl + (int(glst[ii]), )
    ii += 1

try:
    igndb = weather_utils.WeatherDB(weather_db)
except:
    igndb = weather_utils.WeatherDB.create(weather_db)

logging.info('Opening workbook ' + xl_data)
wbk = load_workbook(filename=xl_data)

sht_all = wbk[xl_input_sheet]
try:
    sht_wind = wbk[xl_output_sheet]
except KeyError:
    sht_wind = wbk.copy_worksheet(sht_all)
    sht_wind.title = xl_output_sheet

dtstart = weather_utils.TimeUtils(start_date)
dtend = weather_utils.TimeUtils(end_date)
예제 #3
0
 def test_close(self):
     db_name = 'test/test_weather_data.db'
     mydb = weather_utils.WeatherDB(db_name)
     mydb.close()
     self.assertTrue(mydb.cursor == None)
예제 #4
0
 def test_db_unavailable(self):
     print('WeatherDBTest - test_db_unavailable')
     mydb = None
     with self.assertRaises(FileExistsError):
         mydb = weather_utils.WeatherDB('bogus_db')