-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-quotes-db.py
More file actions
39 lines (31 loc) · 1.02 KB
/
Copy pathcreate-quotes-db.py
File metadata and controls
39 lines (31 loc) · 1.02 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
# Creating a Mongita DB with Quote Info
import json
from mongita import MongitaClientDisk
from datetime import date
quotes_data = [
{
"text":"I enjoy front-end development",
"author": "Josh Romisher",
"public": True,
"date": str(date.today())
},
{
"text": "I like walks and tug of war.",
"author": "Rosie",
"public": True,
"date": str(date.today())
}
]
# Writing the data to a Mongita DB file
# Create Mongita Client connection
client = MongitaClientDisk()
# create a quotes DB
quotes_db = client.quotes_db
# create a quotes collection
quotes_collection = quotes_db.quotes_collection
# empty collection
quotes_collection.delete_many({})
# inserting dictionary of quotes into DB
quotes_collection.insert_many(quotes_data)
#print quotes
print(quotes_collection.count_documents({}))