Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
first_project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
banashree.p
first_project
Commits
d182f2d7
Commit
d182f2d7
authored
Apr 05, 2022
by
banashree.p
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated task1
parent
211a66cb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
0 deletions
+92
-0
assignment_1mongodb/Models/business.py
assignment_1mongodb/Models/business.py
+20
-0
assignment_1mongodb/Repository/repo.py
assignment_1mongodb/Repository/repo.py
+14
-0
assignment_1mongodb/app.py
assignment_1mongodb/app.py
+3
-0
assignment_1mongodb/main.py
assignment_1mongodb/main.py
+25
-0
assignment_1mongodb/mongodb.py
assignment_1mongodb/mongodb.py
+30
-0
No files found.
assignment_1mongodb/Models/business.py
0 → 100644
View file @
d182f2d7
from
pydantic
import
BaseModel
class
business
(
BaseModel
):
_id
:
str
id
:
str
certificate_number
:
str
business_name
:
str
date
:
str
result
:
str
city
:
str
zip
:
str
street
:
str
number
:
str
sector
:
str
address
:
str
Object
:
str
assignment_1mongodb/Repository/repo.py
0 → 100644
View file @
d182f2d7
from
pymongo
import
MongoClient
from
Models.business
import
business
from
main
import
mydb
from
mongodb
import
mongo
def
getData
():
return
mongo
()
def
my_cursor
():
return
None
assignment_1mongodb/app.py
0 → 100644
View file @
d182f2d7
import
uvicorn
uvicorn
.
run
(
"main:app"
)
\ No newline at end of file
assignment_1mongodb/main.py
0 → 100644
View file @
d182f2d7
import
pymongo
myclient
=
pymongo
.
MongoClient
(
"mongodb://192.168.0.220:2747/"
)
mydb
=
myclient
[
"bana"
]
dblist
=
myclient
.
list_database_names
()
if
"bana"
in
dblist
:
print
(
"The database exists."
)
#Create a collection called "customers":
mycol
=
mydb
[
"assignment_1"
]
mycol
.
find
()
print
(
mydb
.
list_collection_names
())
from
fastapi
import
FastAPI
from
mongodb
import
mongo
from
Repository.repo
import
getData
,
my_cursor
app
=
FastAPI
()
@
app
.
get
(
"/getData1"
)
def
showdata
():
return
getData
()
assignment_1mongodb/mongodb.py
0 → 100644
View file @
d182f2d7
from
pymongo
import
MongoClient
def
mongo
():
# client = MongoClient('mongodb://192.168.0.220:2747/')
# result = client['bana']['assignment_1'].aggregate([
temp
=
list
(
mycol
.
aggregate
(
[
{
'$project'
:
{
'_id'
:
'$business_name'
,
'result'
:
'Violation Issued'
}
},
{
'$group'
:
{
'_id'
:
'$_id'
,
'highest'
:
{
'$max'
:
'$result'
}
}
},
{
'$sort'
:
{
'highest'
:
-
1
}
}
]))
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)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment