PyMongo使用IIS连接到数据库

时间:2019-06-13 09:40:20

标签: python mongodb iis pymongo

我正在从IIS运行测试python脚本:

import pymongo
import cgi

print 'Content-Type: text/html'
print ''

db_url="mongodb+srv://myusername:myPassword@some-database.mongodb.net"
myclient = pymongo.MongoClient(db_url)
print(myclient.list_database_names())

当我从命令行运行它时,它可以工作。 但是,当我使用浏览器从IIS运行它时,会得到:

Traceback (most recent call last): 
File "C:\test.py", line 17, in myclient = pymongo.MongoClient(db_url) 
File "C:\python2\lib\site-packages\pymongo\mongo_client.py", line 566, in __init__ username, password, dbase, opts) 
File "C:\python2\lib\site-packages\pymongo\client_options.py", line 158, in __init__ self.__pool_options = _parse_pool_options(options) 
File "C:\python2\lib\site-packages\pymongo\client_options.py", line 129, in _parse_pool_options ssl_context, ssl_match_hostname = _parse_ssl_options(options) 
File "C:\python2\lib\site-packages\pymongo\client_options.py", line 104, in _parse_ssl_options match_hostname) 
File "C:\python2\lib\site-packages\pymongo\ssl_support.py", line 163, in get_ssl_context ctx.load_default_certs() 
File "C:\python2\lib\ssl.py", line 391, in load_default_certs self._load_windows_store_certs(storename, purpose) 
File "C:\python2\lib\ssl.py", line 378, in _load_windows_store_certs for cert, encoding, trust in enum_certificates(storename): WindowsError: [Error 5] Access is denied

0 个答案:

没有答案