#!/usr/bin/env python

import sqlite3
import sys
import Adafruit_DHT

def log_values(sensor_id, temp, hum):
	conn=sqlite3.connect('/var/www/lab_app/lab_app.db')  #It is important to provide an
							     #absolute path to the database
							     #file, otherwise Cron won't be
							     #able to find it!
	curs=conn.cursor()
	curs.execute("""INSERT INTO temperatures values(datetime('now'),
         (?), (?))""", (sensor_id,temp))
	curs.execute("""INSERT INTO humidities values(datetime('now'),
         (?), (?))""", (sensor_id,hum))
	conn.commit()
	conn.close()

humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 17)
if humidity is not None and temperature is not None:
	log_values("1", temperature, humidity)	
else:
	log_values("1", -999, -999)

@@ -16,16 +16,631 @@
 python%0A%0A
+/*%0A%0AFILE NAME%0Aenv_log.py%0A%0A1. WHAT IT DOES%0ATakes a reading from a DHT sensor and records the values in an SQLite3 database using a Raspberry Pi.%0A %0A2. REQUIRES%0A* Any Raspberry Pi%0A* A DHT sensor%0A* A 10kOhm resistor%0A* Jumper wires%0A%0A3. ORIGINAL WORK%0ARaspberry Full stack 2015, Peter Dalmaris%0A%0A4. HARDWARE%0AD17: Data pin for sensor%0A%0A5. SOFTWARE%0ACommand line terminal%0ASimple text editor%0ALibraries:%0Aimport sqlite3%0Aimport sys%0Aimport Adafruit_DHT%0A%0A6. WARNING!%0ANone%0A%0A7. CREATED %0A%0A8. TYPICAL OUTPUT%0ANo text output. Two new records are inserted in the database when the script is executed%0A%0A // 9. COMMENTS%0A--%0A%0A // 10. END%0A%0A*/%0A%0A%0A%0A
 import s

Update env_log.py