1
1
.. _pymongo-tools:
2
2
3
- =====
4
- Tools
5
- =====
3
+ =================
4
+ Third-Party Tools
5
+ =================
6
6
7
7
.. contents:: On this page
8
8
:local:
@@ -15,40 +15,33 @@ Tools
15
15
:values: reference
16
16
17
17
.. meta::
18
- :keywords: pypi, package, web, module, third party, pip
18
+ :keywords: pypi, package, web, module, pip
19
19
20
20
Overview
21
21
--------
22
22
23
- Many developers have written tools for working with {+driver-short+}. If you know
24
- of a tool for working with MongoDB from Python, please list it here.
23
+ This page describes some popular third-party libraries for working with {+driver-short+}.
24
+ With the exception of Motor, all libraries on this page are maintained by the community.
25
+ To keep this list current, projects that haven't been updated recently will
26
+ occasionally be removed from the list or moved to the end.
25
27
26
- .. note::
27
-
28
- To keep this list current, projects that
29
- haven't been updated recently will
30
- occasionally be removed from the list or moved to the end.
28
+ .. tip::
31
29
32
- If we remove a project that is still being developed or is in active use,
33
- please let us know or add it back to the list.
30
+ Although these libraries can be helpful, we recommend that new {+driver-short+} users
31
+ begin by working directly with the driver. {+driver-short+} alone will meet most people's
32
+ needs, and working with it is instructive in how MongoDB works.
34
33
35
34
ORM-like Layers
36
35
---------------
37
36
38
37
ORM-like (object-relational-mapping-like) layers add features like models and validation to
39
38
{+driver-short+}.
40
39
41
- .. tip::
42
-
43
- We recommend that new {+driver-short+} users begin by working directly with
44
- the driver. {+driver-short+} alone will meet most people's needs, and working with
45
- it is instructive in how MongoDB works.
46
-
47
40
- `MincePy <https://mincepy.readthedocs.io/en/latest/>`__ is an
48
41
object-document mapper (ODM) designed to make any Python object storable
49
42
and queryable in a MongoDB database. It was designed with machine learning
50
43
and big-data computational and experimental science applications in mind.
51
- However, it is entirely general and can be useful to anyone looking to organize,
44
+ However, it's entirely general and can be useful to anyone looking to organize,
52
45
share, or process large amounts of data with as little change to their current
53
46
workflow as possible.
54
47
@@ -60,21 +53,20 @@ ORM-like (object-relational-mapping-like) layers add features like models and va
60
53
<http://blog.pythonisito.com/2009/12/ming-01-released-python-library-for.html>`__
61
54
for more details.
62
55
63
- - `MongoEngine <http ://mongoengine.org />`__ lets you use syntax inspired by the
64
- Django ORM to define schemas for documents and query collections.
56
+ - `MongoEngine <https ://mongoengine-odm.readthedocs.io />`__ lets you use syntax inspired
57
+ by the Django ORM to define schemas for documents and query collections.
65
58
The code is available on `GitHub
66
- <http://github.com/mongoengine/mongoengine>`__. For more information, see
67
- the `MongoEngine tutorial <https://docs.mongoengine.org/tutorial.html>`_.
59
+ <http://github.com/mongoengine/mongoengine>`__.
68
60
69
61
- `MotorEngine <https://motorengine.readthedocs.io/>`__ is a port of
70
62
MongoEngine to Motor, allowing asynchronous access with Tornado.
71
- It implements the same modeling APIs to be data-portable, meaning that a
63
+ It implements the same modeling APIs in a data-portable way , meaning that a
72
64
model defined in MongoEngine can be read in MotorEngine. The source is
73
65
available on `GitHub <http://github.com/heynemann/motorengine>`__.
74
66
75
- - `uMongo <https://umongo.readthedocs.io/>`__ is a Python MongoDB ODM.
76
- It was created to meet two needs: the lack of async ODM and the
77
- difficulty to do document serialization with existing ODMs.
67
+ - `uMongo <https://umongo.readthedocs.io/>`__ is a Python MongoDB ODM that
68
+ was created to meet two needs: the lack of an asynchronous ODM and the
69
+ difficulty of serializing documents with other ODMs.
78
70
uMongo works with multiple drivers: PyMongo, TxMongo, motor_asyncio, and
79
71
mongomock. The source is available on `GitHub <https://github.com/Scille/umongo>`__.
80
72
@@ -162,28 +154,29 @@ can do asynchronous I/O with non-blocking sockets and schedule operations
162
154
on `greenlets <https://pypi.org/project/greenlet/>`__ instead of threads.
163
155
164
156
To use gevent with {+driver-short+}, call gevent's
165
- ``monkey.patch_all()`` method before loading any other modules, as shown in the following
157
+ ``monkey.patch_all()`` method * before* loading any other modules, as shown in the following
166
158
example:
167
159
168
160
.. code-block:: python
169
161
170
- >>> # You must call patch_all() *before* importing any other modules
171
- >>> from gevent import monkey
172
- >>> _ = monkey.patch_all()
173
- >>> from pymongo import MongoClient
174
- >>> client = MongoClient()
162
+ # You must call patch_all() *before* importing any other modules
163
+ from gevent import monkey
164
+ _ = monkey.patch_all()
165
+ from pymongo import MongoClient
166
+ client = MongoClient()
175
167
176
168
.. important:: Close MongoClient to Avoid Blocking
177
169
178
170
If you call ``monkey.patch_all()`` when your application launches, ``MongoClient``
179
171
will use greenlets instead of threads to monitor the health of the server.
180
- When shutting down, if your application calls the ``~gevent.hub.Hub.join`` method
172
+ When shutting down, if your application calls the ``~gevent.hub.Hub.join() `` method
181
173
without first terminating these greenlets,
182
- the call to the ``~gevent.hub.Hub.join`` method blocks indefinitely.
174
+ the call to the ``~gevent.hub.Hub.join() `` method blocks indefinitely.
183
175
184
- To avoid this, close or dereference any active ``MongoClient`` before exiting your
185
- application. In some application frameworks, one solution is a signal handler
186
- to end background greenlets when your application receives ``SIGHUP``:
176
+ To avoid this, close or dereference any active ``MongoClient`` objects before exiting
177
+ your application. In some application frameworks, you can use a signal handler
178
+ to end background greenlets when your application receives ``SIGHUP``, as shown
179
+ in the following example:
187
180
188
181
.. code-block:: python
189
182
@@ -198,7 +191,7 @@ example:
198
191
This issue affects applications using uWSGI versions earlier than 1.9.16
199
192
or newer uWSGI versions with the ``-gevent-wait-for-hub`` option.
200
193
For more information, see
201
- ` the uWSGI changelog <https://uwsgi-docs.readthedocs.io/en/latest/Changelog-1.9.16.html#important-change-in-the-gevent-plugin-shutdown-reload-procedure>`__.
194
+ the ` uWSGI changelog <https://uwsgi-docs.readthedocs.io/en/latest/Changelog-1.9.16.html#important-change-in-the-gevent-plugin-shutdown-reload-procedure>`__.
202
195
203
196
.. _pymongo-mod_wsgi:
204
197
@@ -257,7 +250,7 @@ daemon in the global application group:
257
250
258
251
.. note::
259
252
260
- Python C extensions in general have issues running in multiple
253
+ Many Python C extensions have issues when running in multiple
261
254
Python sub-interpreters. These difficulties are explained in the documentation for
262
255
`Py_NewInterpreter <https://docs.python.org/3/c-api/init.html#c.Py_NewInterpreter>`__
263
256
and in the `Multiple Python Sub Interpreters <https://modwsgi.readthedocs.io/en/master/user-guides/application-issues.html#multiple-python-sub-interpreters>`__
0 commit comments