From 22b27cc84935edfc224399035a2fc5151ed11c75 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Wed, 13 Jan 2016 19:57:59 -0600 Subject: [PATCH] Fixed more SolarData stuff --- python/tagserver.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/tagserver.py b/python/tagserver.py index 54f1916..d0140e9 100644 --- a/python/tagserver.py +++ b/python/tagserver.py @@ -19,11 +19,13 @@ import tuxeip from tuxeip import TuxEIP, LGX, LGX_REAL + + def main(): - db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="SolarData") + db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="TagData") cur = db.cursor() - query = "SELECT * FROM SolarData.tags WHERE deleted = 0;" + query = "SELECT * FROM TagData.tags WHERE deleted = 0;" cur.execute(query) tags = cur.fetchall() # ((1L, 'DC_Bus_Voltage', datetime.datetime(2015, 12, 8, 16, 2, 32), 'V', 0L), (2L, 'Output_Frequency', datetime.datetime(2015, 12, 8, 16, 31, 12), 'Hz', 0L)) @@ -31,6 +33,7 @@ def main(): db.close() PLC_IP_ADDRESS = "192.168.1.10" # MAKE THIS A db VALUE + scan_rate = 10 tagList = []; if len(tags) > 0: @@ -48,9 +51,9 @@ def main(): r["val"] = tux.ReadLGXDataAsFloat(sess, conn, r['name'], 1)[0] print("{0} - {1}".format(r["name"], r["val"])) if not r["val"] == r["lastVal"]: - db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="SolarData") + db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="TagData") cur = db.cursor() - aQuery = """INSERT INTO SolarData.values (tagID, val) VALUES ('%d', '%f');"""%(r["id"], float(r["val"])) + aQuery = """INSERT INTO TagData.values (tagID, val) VALUES ('%d', '%f');"""%(r["id"], float(r["val"])) print(aQuery) storeVal = cur.execute(aQuery) db.commit()