Skip to content
Snippets Groups Projects
Commit 5293015b authored by William Bell's avatar William Bell
Browse files

Adding the database name

parent ddef4566
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
import mongo_connect
# Create a client connection to the MongoDB database.
# Get a client connection to the MongoDB database.
client = mongo_connect.get_client()
# Create a new database.
db = client['sales']
db = client[mongo_connect.get_database_name()]
# Create a collection.
customers = db['Customers']
......
......@@ -43,3 +43,10 @@ def get_client():
return None
return client
def get_database_name():
"""
A function to return the MongoDB database name.
"""
return os.getenv('MONGODB_DB', 'test')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment