Я решил спустя долгое время использования SQLite взяться за MongoDB, но сразу же получил ошибку, когда начал добавлять данные (но перед этим прошло время немного). Ошибка говорит что типа Время подключения сессии вышло.
Я сижу уже пятый час уже пролазил где только можно зашел на стак
https://stackoverflow.com/questions/67585023/ssl-c...
там посмотрел скачал какой то сертификат поставил его и всё равно не работает
Пожалуйста помогите хочу освоить MongoDB
Код (я писал бота для вк):
from vkbottle.bot import Bot, Message
from config import mainsettings
import asyncio
import random
from random import randint
from pymongo import MongoClient
bot = Bot(token=mainsettings['token'])
cluster = MongoClient(f"mongodb+srv://zaralx:{mainsettings['clusterpassword']}@profile.t2cgz.mongodb.net/VkProfile?retryWrites=true&w=majority")
db = cluster.VkProfile
UserColl = db.User
@bot.on.private_message()
async def message_handler(message: Message):
if message.text == "Начать":
UserColl.insert_one({"_id": 1, "name": "Player"+str(random.randint(10000, 99999999)), "Cash": 0})
await message.answer("Done")
else:
pass
# Главную откроет
bot.run_forever()
Ошибка которую выдаёт:
Traceback (most recent call last):
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\vkbottle\dispatch\bot_router.py", line 20, in route
await view.handle_event(event, ctx_api, self.state_dispenser)
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\vkbottle\dispatch\views\bot\message.py", line 64, in handle_event
handler_response = await handler.handle(message, **context_variables)
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\vkbottle\dispatch\handlers\from_func_handler.py", line 26, in handle
return await self.handler(event, **context)
File "C:\Users\Miste\Desktop\vk\vk.py", line 25, in message_handler
UserColl.insert_one({"_id": 1, "name": "Player"+str(random.randint(10000, 99999999)), "Cash": 0})
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\collection.py", line 705, in insert_one
self._insert(document,
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\collection.py", line 620, in _insert
return self._insert_one(
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\collection.py", line 609, in _insert_one
self.__database.client._retryable_write(
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\mongo_client.py", line 1551, in _retryable_write
with self._tmp_session(session) as s:
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\mongo_client.py", line 1948, in _tmp_session
s = self._ensure_session(session)
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\mongo_client.py", line 1935, in _ensure_session
return self.__start_session(True, causal_consistency=False)
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\mongo_client.py", line 1883, in __start_session
server_session = self._get_server_session()
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\mongo_client.py", line 1921, in _get_server_session
return self._topology.get_server_session()
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\topology.py", line 520, in get_server_session
session_timeout = self._check_session_support()
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\topology.py", line 504, in _check_session_support
self._select_servers_loop(
File "C:\Users\Miste\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\topology.py", line 218, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: profile-shard-00-01.t2cgz.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108),profile-shard-00-02.t2cgz.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108),profile-shard-00-00.t2cgz.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108), Timeout: 30s, Topology Description: <TopologyDescription id: 6145bb6edce2242b7dbcd19f, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('profile-shard-00-00.t2cgz.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('profile-shard-00-00.t2cgz.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')>, <ServerDescription ('profile-shard-00-01.t2cgz.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('profile-shard-00-01.t2cgz.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')>, <ServerDescription ('profile-shard-00-02.t2cgz.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('profile-shard-00-02.t2cgz.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')>]>