Skip to content

Commit f34b436

Browse files
committed
Remove part that auto-creates database. (Will happen with local.)
1 parent b6e3e2f commit f34b436

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

azureproject/restaurant_review/mongodb.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,9 @@ def get_collection():
1616
except pymongo.errors.ServerSelectionTimeoutError:
1717
raise TimeoutError("Invalid API for MongoDB connection string or timed out when attempting to connect")
1818

19-
collection = create_database_unsharded_collection(client, DB_NAME, COLLECTION_NAME)
20-
return collection
21-
22-
def create_database_unsharded_collection(client, DB_NAME, COLLECTION_NAME):
23-
"""Create sample database with shared throughput if it doesn't exist and an unsharded collection"""
2419
db = client[DB_NAME]
25-
26-
# Create database if it doesn't exist
27-
if DB_NAME not in client.list_database_names():
28-
# Database with 400 RU throughput that can be shared across the DB's collections
29-
db.command({'customAction': "CreateDatabase", 'offerThroughput': 400})
30-
print("Created db {} with shared throughput". format(DB_NAME))
31-
32-
# Create collection if it doesn't exist
33-
if COLLECTION_NAME not in db.list_collection_names():
34-
# Creates a unsharded collection that uses the DBs shared throughput
35-
db.command({'customAction': "CreateCollection", 'collection': COLLECTION_NAME})
36-
print("Created collection {}". format(COLLECTION_NAME))
37-
print("Collection name {}". format(db.COLLECTION_NAME))
38-
3920
return db[COLLECTION_NAME]
4021

41-
4222
def create_restaurant_record(name, street_address, description):
4323
ts = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
4424
restaurant_record = {

0 commit comments

Comments
 (0)