Ejemplo n.º 1
0
def getData(patient):
    db = DB(patient, DATABASE)

    print patient

    try:
        data = db.getData(datetimes=False)
    except:
        return Response(response="{\"ERROR\": \"Invalid PID\"}",
                        status=404,
                        mimetype="application/json")

    print "got the data from DB"

    d = makeJsonObj(data)

    # return jsonify(data)
    return Response(response=d, status=200, mimetype="application/json")
Ejemplo n.º 2
0
def uploadCSV(patient):
    if request.method == 'POST':  #If they are sending a file
        if 'file' not in request.files:  #check to see if there are any files
            return Response(response='{"ERROR":"Missing file in request"}',
                            status=400,
                            mimetype="application/json")
        else:
            file = request.files['file']  #get tile
            if file.filename == '':
                return Response(
                    response='{"ERROR":"No selected file in request"}',
                    status=400,
                    mimetype="application/json")
            if file and isCSV(file.filename):
                db = DB(patient, DATABASE)
                db.insertData(file)
                return Response(
                    response='{"SUCCESS":"File was uploaded to the database"}',
                    status=400,
                    mimetype="application/json")
    else:  #send back upload form
        return '''
Ejemplo n.º 3
0
def addColumn(patient):
    db = DB(patient, 'dat.db')
    inJsonData = request.json
    dictList = []

    #Sprint(type(inJsonData))

    #inJsonData = inJson.loads(inJson)
    newColName = inJsonData.keys()[0]

    for dictEntry in inJsonData[newColName]:
        key = dictEntry.keys()[0]
        listEntry = {int(key): dictEntry[key]}
        dictList.append(listEntry)

    #print(type(dictList[0]))

    db.addColumn(newColName, dictList)

    R = Response(response='{"SUCCESS":"Column added to the database"}',
                 status=200,
                 mimetype="application/json")
    R.headers["Access-Control-Allow-Origin"] = "http://localhost:5000"
    return R
Ejemplo n.º 4
0
from dataAccess import dataAccess as DB
import datetime as DT

dbpath="Kate.db"

##Connect to the Database by creating an instance of dataAccess 
Katedb = DB("Kate",dbpath)
print "db connected"

dict1={0: 0}  
dict2={0: '"0"'}
#Here we create two dummy dictionaries to send to the database via addcolumn.
#This will allow dataAccess.py to know what type it should populate the column with. 

names= Katedb.getColumnNames()
print " Before: ", names

#This is before we add our colums


Katedb.addColumn("randomNums", dict1)
Katedb.addColumn("stringColumn", dict2)
# Add in our two new columns!

names= Katedb.getColumnNames()
print "After: ", names
# Now you should see the names of the columns you added.
Ejemplo n.º 5
0
from dataAccess import dataAccess as DB
import datetime as dt
import glob
import os.path
import sys

dbpath = "Kate.db"

pidKate = "Kate"
db = DB(pidKate, dbpath)
datapath2 = "Kate_G5_Aug8_Aug24_2016.csv"
db.insertData(datapath2)

db = DB(pidKate, dbpath)
datapath3 = "Kate_G5_July_6_Oct_3_2016.csv"
db.insertData(datapath3)

db = DB(pidKate, dbpath)
datapath4 = "Kate_G5_Oct_8_Oct_14.csv"
db.insertData(datapath4)

print("inserted data")
Ejemplo n.º 6
0
from dataAccess import dataAccess as DB
import datetime as DT

#connect to the database
dbpath = "lab.db"

#connect to the Database by creating an instance of dataAccess
kateDB = DB("Kate", dbpath)

#datetime would look this this
at = DT.datetime.strptime("2016-06-13 00:04:38", "%Y-%m-%d %H:%M:%S")
#valueList would look like this
valueList = {"at": 2413, "carb": 204}

#call the function on the Kate table with new data for the specific row
kateDB.updateRow(at, valueList)