Commit 60e4d24d authored by Landon DeCoito's avatar Landon DeCoito
Browse files

started database implementation. added to facilitate that

parent f4c6fb68
......@@ -10,8 +10,15 @@ from getconnectedscript import load_getconn_data
# python imports
import json
# other imports
import redis
from redisactions import *
# setting up flask instance
app = Flask(__name__)
# setting up redis database
redisdb = redis.from_url("redis://localhost:6379/0", db=0)
def display_default():
......@@ -21,15 +28,15 @@ def display_default():
def display_data():
resp = Response(json.dumps(load_data(), ensure_ascii=False)
livedbfill(json.dumps(load_data(), ensure_ascii=False))
resp = Response(redisdb.get("livedict")) # .encode('utf-8'))
resp.headers['Content-Type'] = 'application/json; charset=utf-8'
return resp
def display_GC_data():
resp = Response(json.dumps(load_getconn_data(), ensure_ascii=False)
gcdbfill(json.dumps(load_getconn_data(), ensure_ascii=False))
resp = Response(redisdb.get("gcdict")) # .encode('utf-8'))
resp.headers['Content-Type'] = 'application/json; charset=utf-8'
return resp
# third party imports
import redis
from __init__ import redisdb
# I'm thinking we store a couple things
# first: a key-value where the value is the dictlist
# second: a k-v for a list of errored events
# use rpush(key, value) to append a dblist (rpushx() to check if it exists)
# use del(key) to remove a k-v
# so we everytime we run parscript or gcscript we want to run a dbfill()
# function. and every time we find an error we want to run a dberrorfill()
# function.
# this will update the
# returns true if the dictlist is not empty, false otherwise
def gcdbfill(dictlist):
redisdb.set("gcdict", dictlist)
except e:
return False
if redisdb.get("gcdict") is not None:
return True
return False
# saves new dictlist in place of previous 25Live dictlist
# returns true if the dictlist is empty, false otherwise
def livedbfill(dictlist):
redisdb.set("livedict", dictlist)
except e:
return False
if redisdb.get("livedict") is not None:
return True
return False
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment