-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_inspector.py
38 lines (28 loc) · 930 Bytes
/
db_inspector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import pymongo
from pprint import pprint
client = pymongo.MongoClient('mongodb://localhost:27017/db')
db = client.get_default_database()
collections = ['people',
'events',
'reservations',
'rideshares',
'requests']
def find_stuff(stuff):
found = [x for x in db[stuff].find()]
print(">> {}".format(stuff))
pprint(found)
print()
return found
for collection in collections:
find_stuff(collection)
if len(sys.argv) == 2:
if sys.argv[1] == 'remove':
db[collection].remove()
# db.rideshares.remove()
# people = [x for x in db.people.find()]
# events = [x for x in db.events.find()]
# reservations = [x for x in db.reservations.find()]
# rideshares = [x for x in db.rideshares.find()]
# requests = [x for x in db.requests.find()]
print([x for x in db.people.find({'email': 'ryan.austin.carlson@gmail.com'})])