def create_ifnot_onrecord(self, table, name):
    record = self.db.one("SELECT name, network FROM " + table + " WHERE LOWER(name)=LOWER(%s) AND LOWER(network)=LOWER(%s)", (name, self.network, ))
    
    
    if record:  # On record.
        # Correct capitalisation of network name, if needed.
        if not self.network == record[1]:
            self.db.run("UPDATE networks SET name=%s WHERE LOWER(name)=LOWER(%s)", (self.network, self.network, ))
        
        # Correct capitalisation if needed.
        if not name == record[0]:
            self.db.run("UPDATE " + table + " SET name=%s WHERE LOWER(name)=LOWER(%s) AND network=%s", (name, name, self.network, ))
    
    # Create record.
    else:
        self.db.run("INSERT INTO " + table + " (name, network) VALUES (%s, %s)", (name, self.network, ))
