Exemple #1
0
def add_reading(celsius, fahrenheit):
    """
    Adds a reading to the database
    :param celsius:
    :param fahrenheit:
    :return:
    """
    sql = 'INSERT INTO `readings` (`location`, `reading_time`, `celsius`, ' \
          '`fahrenheit`) VALUES (%(location)s, %(now)s, %(celsius)s, ' \
          '%(fahrenheit)s)'

    data = {
        'location': get_config('location', 'UNKNOWN'),
        'now': datetime.now(),
        'celsius': celsius,
        'fahrenheit': fahrenheit,
    }

    execute(sql, data)