def setup(self):
    cursor = self.connection.cursor()
    try:
        cursor.execute('select count(*) from events')
    except Exception as e:
        logging.getLogger('garage').info('Required table not found... creating events table...')
        cursor.execute('create table events(\n                ID INTEGER PRIMARY KEY   AUTOINCREMENT,\n                DT DATETIME DEFAULT CURRENT_TIMESTAMP,\n                EVENT TEXT);')
        logging.info('done!')
    finally:
        cursor.close()
        self.connection.commit()
    cursor = self.connection.cursor()
    try:
        cursor.execute('select count(*) from settings')
    except Exception as e:
        logging.getLogger('garage').info('Required table not found... creating settings table...')
        cursor.execute('CREATE TABLE "settings" (\n                    "id" INTEGER PRIMARY KEY AUTOINCREMENT,\n                    "check_interval_mins" INTEGER DEFAULT (2),\n                    "notify_interval_mins" INTEGER DEFAULT (30),\n                    "warning_threshold_mins" INTEGER DEFAULT (15),\n                    "sentry_mode" INTEGER DEFAULT (0))')
        self.connection.commit()
        cursor.execute('insert into settings (id) values (1)')
        logging.info('done!')
    finally:
        cursor.close()
        self.connection.commit()
def setup(self):
    cursor = self.connection.cursor()
    try:
        cursor.execute('select count(*) from events')
    except Exception as e:
        logging.getLogger('garage').info('Required table not found... creating events table...')
        cursor.execute('create table events(\n                ID INTEGER PRIMARY KEY   AUTOINCREMENT,\n                DT DATETIME DEFAULT CURRENT_TIMESTAMP,\n                EVENT TEXT);')
        logging.info('done!')
    finally:
        cursor.close()
        self.connection.commit()
    cursor = self.connection.cursor()
    try:
        cursor.execute('select count(*) from settings')
    except Exception as e:
        logging.getLogger('garage').info('Required table not found... creating settings table...')
        cursor.execute('CREATE TABLE "settings" (\n                    "id" INTEGER PRIMARY KEY AUTOINCREMENT,\n                    "check_interval_mins" INTEGER DEFAULT (2),\n                    "notify_interval_mins" INTEGER DEFAULT (30),\n                    "warning_threshold_mins" INTEGER DEFAULT (15),\n                    "sentry_mode" INTEGER DEFAULT (0))')
        self.connection.commit()
        cursor.execute('insert into settings (id) values (1)')
        logging.info('done!')
    finally:
        cursor.close()
        self.connection.commit()