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

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

cur = db.cursor()


@@ -1,128 +1,808 @@
-%0Ahttps://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html%0A%0A#SQL Connection Test%0Aimport MySQLdb
+#!/usr/bin/env python%0A%0A#import sys%0A#import os%0A#import logging%0A#import pif%0Aimport MySQLdb%0A%0A# https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html%0A%0A%0A# GLOBALS%0AMYSQL_USERNAME=%22USERNAME%22%0AMYSQL_PASSWORD=%22PASSWORD%22%0A%0A%0A %0A#%0A# check locally if IP has changed%0A#%0Adef check_ip_file(public_ip):%0A  if os.path.exists(IPFILE):%0A    # Open a file%0A    fo = open(IPFILE, %22r%22)%0A    old_ip = fo.read(50)%0A    fo.close()%0A    #print %22Read String is : %22, str%0A    # Close opend file%0A    if old_ip == public_ip:%0A      print %22ip is the same.. not doing anything%22%0A      return 1%0A  # return if no file exists, or the IP is new%0A  return%0A %0A%0A %0A### BEGIN MAIN PROCEDURE%0A%0Apoll_all_sensors()%0Apublic_ip = pif.get_public_ip()%0A %0Aif check_ip_file(public_ip) != 1:%0A  update_dns(public_ip)%0A  %0A  #SQL Connection Test
 %0Adb 
@@ -888,17 +888,16 @@
 g-hub%22)%0A
-%0A
 cur = db
@@ -906,9 +906,11 @@
 ursor()%0A
+  
 %0A

Update poll.py