#!/usr/bin/env python

#import sys
#import os
#import logging
#import pif
import MySQLdb

# https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html


# GLOBALS
MYSQL_USERNAME="pi"
MYSQL_PASSWORD="PASSWORD"


 
#
# check locally if IP has changed
#

 
def poll_all_sensors():
  import datetime
  import mysql.connector
  
  servername = "localhost";
  username = "pi";
  password = "password";
  dbname = "pi_heating_db";

  cnx = MySQLdb.connect(host=servername, user=username, passwd=password, db=dbname)
  cursor = cnx.cursor()

  query = ("SELECT * FROM sensors")

  cursor.execute(query)
  
  results =cursor.fetchall()
  cursor.close()
  
  for i in results:
       print i


  cnx.close()
  
  # read list of sensors
  # loop through sensors write values to db
  # 

  return
 
def update_all_timers():
  return

def action_all_schedules():
  return

### BEGIN MAIN PROCEDURE ###

#db = MySQLdb.connect(host="localhost", user="pi", passwd="password", db="pi-heating-hub")

poll_all_sensors()

update_all_timers()

action_all_schedules()

@@ -82,16 +82,56 @@
 MySQLdb%0A
+import datetime%0Aimport mysql.connector%0A 
 %0A# https
@@ -341,16 +341,17 @@
 rs():%0A  
+#
 import d
@@ -360,16 +360,17 @@
 etime%0A  
+#
 import m

Update poll.py