Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何避免在连接mongodb时提示PEM密码短语?_Python_Mongodb - Fatal编程技术网

Python 如何避免在连接mongodb时提示PEM密码短语?

Python 如何避免在连接mongodb时提示PEM密码短语?,python,mongodb,Python,Mongodb,我正在尝试使用ssl连接到mongodb,如下所示,连接到mongo提示输入PEM密码短语:,如何避免此提示 from pymongo import MongoClient database_name = "iso_change_life_cycle_qa" collection_name= "mymongocollection" def get_db(): try: # Following are the paths for certificates created by PI

我正在尝试使用ssl连接到mongodb,如下所示,连接到mongo提示
输入PEM密码短语:
,如何避免此提示

from pymongo import MongoClient

database_name = "iso_change_life_cycle_qa"
collection_name= "mymongocollection"

def get_db():
  try:
    # Following are the paths for certificates created by PIE environment. As long as
    # your PIE app environment is authroized by PIE FDB SRE, following should just work.
    client = MongoClient('iso-change-life-cycle-qa-s01.mongo-api.storage.pie.g.company.com',
                         ssl=True,
                         ssl_certfile='/Users/username/Documents/pythonscripts/change_lifecycle.apple.com.chain.pem',
                         ssl_keyfile='/Users/username/Documents/pythonscripts/change_lifecycle.apple.com.key.pem')

    db = client[database_name]
    return db
  except Exception as e:
    print (e.__str__())

def main():
  while True:
    try:
      db= get_db()
      print "db" 
      print db
    except Exception as e:
      print (e.__str__())

if __name__ == "__main__":
  main()
错误:- 运行脚本提示

python testdb.py 
Enter PEM pass phrase:
根据文件;

client=pymongo.MongoClient('example.com',
ssl=True,
ssl_certfile='/path/to/client.pem',
ssl_keyfile='/path/to/key.pem',
ssl\u pem\u密码短语=)
 client = pymongo.MongoClient('example.com',
                             ssl=True,
                             ssl_certfile='/path/to/client.pem',
                             ssl_keyfile='/path/to/key.pem',
                             ssl_pem_passphrase=<passphrase>)