#!/usr/bin/python
import sys
import Adafruit_DHT
import time
import _mysql

sensor = Adafruit_DHT.DHT11
pin = 4
host = 'mydbinstance.caikea6db5cp.eu-central-1.rds.amazonaws.com'
user = 'dan192000'
passwd = 'Cost.norml19'
db = 'dan192000'
port = 3306


try:
    connection = _mysql.connect(host, user, passwd, db, port)

    #connection.query('insert into `weather_dashboard`(date,temperature,humidity) values("2019-02-02 00:00:00",20,20)')
    if connection.open:
       
 print("Connected to MySQL database")
except:
    print ("Error while connecting to MySQL")



'''
while True:

	#time.sleep(5)

	#tuple, functions can return multiple values
	humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

	#{0} - first element from .format(), :0.1f - formating
	print 'Temp: {0:0.1f} C  Humidity: {1:0.1f} %'.format(temperature, humidity)
'''
