Я пытаюсь соединиться с MongoDB Atlas, используя motor и asyncio, но я продолжаю получать ServerSelectionTimetoutError.
import asyncio
import motor.motor_asyncio
import urllib
class DBManager:
def __init__(self):
self.loop = asyncio.new_event_loop()
self.client = motor.motor_asyncio.AsyncIOMotorClient("mongodb://500PlusClient:TopSecretPassword@500plus-shard-00-00-1kawz.azure.mongodb.net:27017,500plus-shard-00-01-1kawz.azure.mongodb.net:27017,500plus-shard-00-02-1kawz.azure.mongodb.net:27017/test?ssl=true&replicaSet=500Plus-shard-0&authSource=admin&retryWrites=true&w=majority", io_loop=self.loop)
async def insert_to_database(self, product):
await self.client.ProjektProducts.produkty.insert_one(product)
async def get_products(self):
db = self.client.test
collection = db.products
object = await collection.find_one({"song": "Young Thug - Relationship"})
for objects in object:
print(objects)
def update_products(self):
collection = self.client.test.products
collection.update_one({'song': 'exampletitle'}, {"$set": {'is_awesome': "indeed"}})
db = DBManager()
db.loop.run_until_complete(db.get_products())
db.loop.close()