-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongoqueries.py
More file actions
55 lines (49 loc) · 1.27 KB
/
Copy pathmongoqueries.py
File metadata and controls
55 lines (49 loc) · 1.27 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pymongo
import vidtotext
client = None
db = None
collection = None
def mongo_connect():
global client, collection, db
connection_string = "mongodb://mongoadmin:mongopassword@localhost:35945/"
client = pymongo.MongoClient(connection_string)
db = client["slang_data"]
collection = db["word_dataset"]
print("we got a connection ;]")
def mongo_disconnect():
global client
if client == None:
print("No client created stupid")
else:
client.close()
print("*indian accent* he disconnected (the client)")
def insert_transcripts(transcripts):
global collection
if collection == None:
print("connect to the db my brotha")
else:
collection.insert_many(transcripts)
print("it went in :D")
def get_transcripts():
global collection
if collection == None:
print("collection could not be found")
return None
else:
documents = collection.find()
for doc in documents:
print(doc)
return documents
def delete_data():
global client, db
if db == None:
print("db does not exist")
else:
client.drop_database(db)
print("db deleted")
'''
mongo_connect()
delete_data()
get_transcripts()
mongo_disconnect()
'''