Pymongo尝试连接到mongodb时抛出“ KeyError:'errmsg'”

时间:2018-07-13 22:48:05

标签: python mongodb pymongo

我正在使用以下代码连接到mongo:

full = "mongodb+srv://myuser:mypass@hpechatops-dzlpw.mongodb.net/test?retryWrites=true"
client = MongoClient(full)
db = client.admin

serverStatusResult=db.command("serverStatus")
pprint(serverStatusResult)

我收到此错误:

errmsg - details["errmsg"]
KeyError: 'errmsg'

这并不能真正告诉我很多,所以我很难弄清楚出什么问题了。这段代码源于诸如https://scotch.io/tutorials/getting-started-with-python-and-mongodb这样的教程。

1 个答案:

答案 0 :(得分:0)

尝试一下:

<!-- 
        <action name="UploadLeavesData">
             <interceptor-ref name="authStack"></interceptor-ref>
            <result name="error">view/common/error.jsp</result>
            <result name="success">view/employees/uploadEmpLeavesFileFromGreytHr.jsp</result>
        </action>

        <action name="importLeaves" class="com.zCon.controller.LeaveFileUploadAction" method="execute">
            <interceptor-ref name="fileUpload">
                <param name="maximumSize">20971520</param>
                <param name="allowedTypes">  
                    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/octet-stream
                </param>  
            </interceptor-ref>  
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <result name="input">view/employees/uploadEmpLeavesFileFromGreytHr.jsp</result>
            <result name="success" type="redirect">UploadLeavesData</result>
        </action>
 -->