Beispiel #1
0
# *** TABLES CONTAINING DATA WHICH IS REFRESHED EACH TIME, AND THEREFORE CAN BE DROPPED SAFELY ***
TABLES = {}
TABLES['dailyInfected'] = ("CREATE TABLE `dailyInfected` ("
                           "  `infected` int(11) NOT NULL,"
                           "  `hospitalised` int(11) DEFAULT 0 NOT NULL,"
                           "  `deceased` int(11) DEFAULT 0 NOT NULL,"
                           "  `date` date NOT NULL,"
                           "  PRIMARY KEY (`date`)"
                           ") ENGINE=InnoDB")

# Loop over the array
for table_name in TABLES:
    table_description = TABLES[table_name]

    print("Dropping table %s if it exists" % format(table_name))
    db.executeQuery('DROP TABLE IF EXISTS %s' % str(table_name))

    print("Creating table %s " % format(table_name))
    db.executeQuery(table_description)

# *** TABLES FOR WHICH DATA IS NOT REFRESHED, SO THEY CAN'T BE DROPPED ***
# Array containing create statements for tables.
PERSISTENTTABLES = {}
PERSISTENTTABLES['temperatureLog'] = ("CREATE TABLE `temperatureLog` ("
                                      "  `temperature` DECIMAL(5,1) NOT NULL,"
                                      "  `date` datetime NOT NULL,"
                                      "	 `alerttext TEXT"
                                      "  PRIMARY KEY (`date`)"
                                      ") ENGINE=InnoDB")

# Loop over the array