May-20-2017, 09:57 AM
This is the first few lines of what I have for remote access to database.
Don't know what pymysql is but to my knowledge all the mySQL derivatives work the same.
# working live JP 20170312 # boilergraph.py to display boiler temperatures 20170502 import MySQLdb import time import datetime import matplotlib.pyplot as plt import matplotlib.dates as mdates import matplotlib.animation as animation from matplotlib import style from time import sleep style.use('ggplot') fig = plt.figure() ax1 = fig.add_subplot(1,1,1) dt = [] a = [] b = [] ca = [] d = [] dtf=[] dtg=[] i=0 lr=0 def read_from_db(): del dt[:] del a[:] del b[:] del ca[:] del d[:] del dtf[:] del dtg[:] global lr conn = MySQLdb.connect("192.168.1.162","user1","passuser1","jp1") c = conn.cursor() c.execute('SELECT * FROM boiltbl WHERE dt >= now() - interval 2 hour')Just ignore the poor form and extra stuff. This works great, although, as mentioned took some effort to get the users and passwords set up to mySQL's liking.
Don't know what pymysql is but to my knowledge all the mySQL derivatives work the same.