python连接、查询mongo数据库-pymongo

版本不兼容问题:指定安装对应版本进行兼容
pip install pymongo==3.10.1

写代码

import pymongo
 
def findAndImport():

    # 查询mongo的数据
    client = MongoClient("mongodb://ip:27017/")
    database = client["库名"]
    collection = database["表名"]
	
	#接下来就可以查询啦!
	# Created with Studio 3T, the IDE for MongoDB - https://studio3t.com/
	#一般工具都提供了转换mongo查询语句的功能
posted @ 2022-03-02 18:35  快乐的海盗  阅读(231)  评论(0编辑  收藏  举报