몽고DB 연결을 윈도우에서 한 번 한 후 (이땐 잘 됐어요) 맥에서도 해보려고 하니 잘 안됩니다. 코드는 이렇습니다.
from pymongo import MongoClient
client = MongoClient(
"mongodb+srv://test:sparta@cluster0.ixhh4.mongodb.net/Cluster0?retryWrites=true&w=majority")
db = client.dbsparta
# 'users'라는 collection에 {'name':'bobby','age':21}를 넣습니다.
db.users.insert_one({'name':'bobby','age':21})
db.users.insert_one({'name':'kay','age':27})
db.users.insert_one({'name':'john','age':30})
무엇이 문제일까요? 패키지는 설치 되어 있습니다
아래는 오류 메세지
(venv) daeun@gimda-eun-ui-Mac-Studio python % cd /Users/daeun/Downloads/sparta/python ; /usr/bin/env /Users/daeun/Downloads/sparta/python/venv/bin/python /Users/daeun/.vscod e/extensions/ms-python.python-2022.10.1/pythonFiles/lib/python/debugpy/adapter/../../de bugpy/launcher 50497 -- /Users/daeun/Downloads/sparta/python/dbparc.py Traceback (most recent call last): File "/Users/daeun/Downloads/sparta/python/dbparc.py", line 8, in <module> db.users.insert_one({'name':'bobby','age':21}) File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/collection.py", line 606, in insert_one self._insert_one( File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/collection.py", line 547, in _insert_one self.__database.client._retryable_write(acknowledged, _insert_command, session) File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1398, in _retryable_write with self._tmp_session(session) as s: File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 135, in __enter__ return next(self.gen) File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1676, in _tmp_session s = self._ensure_session(session) File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1663, in _ensure_session return self.__start_session(True, causal_consistency=False) File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1608, in __start_session self._topology._check_implicit_session_support() File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/topology.py", line 519, in _check_implicit_session_support self._check_session_support() File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/topology.py", line 535, in _check_session_support self._select_servers_loop( File "/Users/daeun/Downloads/sparta/python/venv/lib/python3.10/site-packages/pymongo/topology.py", line 227, in _select_servers_loop raise ServerSelectionTimeoutError( pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-02.ixhh4.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997),cluster0-shard-00-01.ixhh4.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997),cluster0-shard-00-00.ixhh4.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997), Timeout: 30s, Topology Description: <TopologyDescription id: 62d523e0b7f29ce4adcd25e2, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('cluster0-shard-00-00.ixhh4.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-00.ixhh4.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')>, <ServerDescription ('cluster0-shard-00-01.ixhh4.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-01.ixhh4.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')>, <ServerDescription ('cluster0-shard-00-02.ixhh4.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-02.ixhh4.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')>]>