db methods comments student

This commit is contained in:
Raffu Khondaker 2020-06-16 15:00:39 -04:00
parent a4ba6f427e
commit 9fa43809cb

View File

@ -28,30 +28,34 @@ def getStudent(ion_user):
return None return None
print(r.status_code) print(r.status_code)
#makes a GET request to given url, returns dict
def getDB(url): def getDB(url):
r = requests.get(url = url, auth=('raffukhondaker','hackgroup1')) r = requests.get(url = url, auth=('raffukhondaker','hackgroup1'))
print("GET:" + str(r.status_code)) print("GET:" + str(r.status_code))
return(r.json()) return(r.json())
#makes a PATCH (updates instance) request to given url, returns dict
def patchDB(data, url):
r = requests.patch(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
print("PATCH:" + str(r.status_code))
return(r.json())
#makes a POST (makes new instance) request to given url, returns dict
def postDB(data, url): def postDB(data, url):
r = requests.post(url = url, data=data, auth=('raffukhondaker','hackgroup1')) r = requests.post(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
print("POST:" + str(r.status_code)) print("POST:" + str(r.status_code))
return(r.json()) return(r.json())
#makes a PUT (overwrites instance) request to given url, returns dict
def putDB(data, url): def putDB(data, url):
r = requests.put(url = url, data=data, auth=('raffukhondaker','hackgroup1')) r = requests.put(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
print("PUT:" + str(r.status_code)) print("PUT:" + str(r.status_code))
return(r.json()) return(r.json())
def patchDB(data, url): #makes a DELETE (delete instance) request to given url, returns dict
r = requests.patch(url = url, data=data, auth=('raffukhondaker','hackgroup1'))
print("PATH:" + str(r.status_code))
return(r.json())
def delDB(url): def delDB(url):
r = requests.delete(url = url, auth=('raffukhondaker','hackgroup1')) r = requests.delete(url = url, auth=('raffukhondaker','hackgroup1'))
print("DELETE:" + str(r.status_code)) print("DELETE:" + str(r.status_code))
return None
def command(command): def command(command):
ar = [] ar = []