@@ -16,29 +16,9 @@ def get_collection():
16
16
except pymongo .errors .ServerSelectionTimeoutError :
17
17
raise TimeoutError ("Invalid API for MongoDB connection string or timed out when attempting to connect" )
18
18
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"""
24
19
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
-
39
20
return db [COLLECTION_NAME ]
40
21
41
-
42
22
def create_restaurant_record (name , street_address , description ):
43
23
ts = datetime .now ().strftime ("%d/%m/%Y %H:%M:%S" )
44
24
restaurant_record = {
0 commit comments