So I deploy my python project using docker and docker-compose and I want to connect mongodb(it is not on the same host) using pymongo and I see some example that include their username/password in the connection string like this.
from pymongo import MongoClient
username = 'pattypatty'
password = 'notrealpwd'
host = 'db.pattypatty.com'
port = '27017'
connection_str = f'mongodb://{username}:{password}@{host}:{port}'
client = MongoClient(connection_str)
I want to try it but, is it safe including your username and password in python code? if not how should I secure my username and password.