Python Data Access 简明教程

Python MongoDB - Introduction

Pymongo是一个python发行版,提供了与MongoDB一起使用的工具,它是从python与MongoDB数据库进行通信的首选方式。

Pymongo is a python distribution which provides tools to work with MongoDB, it is the most preferred way to communicate with MongoDB database from python.

Installation

要安装pymongo,首先确保已正确安装python3(以及PIP)和MongoDB。然后执行以下命令。

To install pymongo first of all make sure you have installed python3 (along with PIP) and MongoDB properly. Then execute the following command.

C:\WINDOWS\system32>pip install pymongo
Collecting pymongo
Using cached https://files.pythonhosted.org/packages/cb/a6/b0ae3781b0ad75825e00e29dc5489b53512625e02328d73556e1ecdf12f8/pymongo-3.9.0-cp37-cp37m-win32.whl
Installing collected packages: pymongo
Successfully installed pymongo-3.9.0

Verification

安装pymongo后,打开一个新的文本文档,将以下行粘贴到其中,并将其另存为test.py。

Once you have installed pymongo, open a new text document, paste the following line in it and, save it as test.py.

import pymongo

如果您已正确安装pymongo,如果按照以下方式执行test.py,则不应该出现任何问题。

If you have installed pymongo properly, if you execute the test.py as shown below, you should not get any issues.

D:\Python_MongoDB>test.py
D:\Python_MongoDB>