Hello,
I am trying to connect to MongoDB.
But receiving ServerSelectionTimeoutError
what should i do?
this is my code :
user_name=st.secrets['database']['user_name']
password=st.secrets['database']['password']
dbase=st.secrets['database']['dbase']
koleksiyon=st.secrets['database']['koleksiyon']
# MongoDB connection URI
uri = "mongodb+srv://" + user_name + ":"+ password + "@msl.9vzzu.mongodb.net/?retryWrites=true&w=majority&appName=msl"
# Create a new client and connect to the server
client = MongoClient(uri, server_api=ServerApi('1'))
# Select the database and collection
db = client[dbase] # Replace with your actual database name
collection = db[koleksiyon] # Replace with your actual collection name
# New document to insert
new_document = {
"company": "easy-free",
"email": mail,
"date": tarh
}
# Insert the document into the collection
insert_result = collection.insert_one(new_document)