Commit cb17923b authored by banashree.p's avatar banashree.p

subtask 1,2

parent d182f2d7
from idlelib.multicall import r
import pymongo
myclient = pymongo.MongoClient("mongodb://192.168.0.220:2747/")
mydb = myclient["bana"]
......@@ -15,7 +17,7 @@ print(mydb.list_collection_names())
from fastapi import FastAPI
from mongodb import mongo
from mongodb import mongo, get_nvi
from Repository.repo import getData, my_cursor
app = FastAPI()
......@@ -23,3 +25,8 @@ app = FastAPI()
def showdata():
return getData()
@app.get("/getData2")
def showdata2():
return get_nvi()
from pymongo import MongoClient
def mongo():
# client = MongoClient('mongodb://192.168.0.220:2747/')
# result = client['bana']['assignment_1'].aggregate([
temp=list(mycol.aggregate(
temp = list(mycol.aggregate(
[
{
'$project': {
......@@ -23,8 +25,17 @@ def mongo():
}
]))
return (temp[0])
# Requires the PyMongo package.
# https://api.mongodb.com/python/current
from main import mydb, mycol
# mydb.teams.find().sort({result:-1}).limit(1)
def get_nvi():
r = mycol.find({"result": "No Violation Issued"})
lst = []
for i in r:
lst.append(i["business_name"])
return lst
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