Monguo
- Info:
Monguo is a full-featured, asynchronous MongoDB ORM with Motor dirver for Tornado applications.
- Author:
Lime YH.Shi
About
Monguo is an asynchronous MongoDB ORM based on driver Motor. The source is on GitHub and the docs are on ReadTheDocs.
Installation
$ pip install git+https://github.com/mongodb/motor.git
$ pip install monguo
Dependencies
Monguo works in all the environments officially supported by Tornado and Motor. It requires:
Examples
class UserDocument(Document):
name = StringField(required=True, unique=True, max_length=20)
email = EmailField(required=True)
age = IntegerField()
sex = StringField(required=True, default='male',
candidate=['male', 'female'])
meta = {
'collection': 'user'
}
def get_user_list(skip=10, limit=5):
result = yield UserDocument.find().to_list(limit)
raise gen.Return(result)
class CommentDocument(EmbeddedDocument):
commentor = ReferenceField(UserDocument, required=True)
contents = StringField(required=True, max_length=200)
class PostDocument(Document):
author = ReferenceField(UserDocument, required=True)
publish_time = DateTimeField(required=True)
title = StringField(required=True, max_length=100)
contents = StringField(max_length=5000)
comments = ListField(EmbeddedDocumentField(CommentDocument))
meta = {
'collection': 'post'
}
# connect to database
Connection.connect('test')
# insert
bob_id = yield UserDocument.insert({
'name': 'Bob',
'email': 'bob@gmail.com',
'age': 19
})
alice_id = yield UserDocument.insert({
'name': 'Alice',
'email': 'alice@gmail.com',
'sex': 'female',
'age': 18
})
post_id = yield PostDocument.insert({
'author': DBRef(UserDocument.meta['collection'], bob_id),
'publish_time': datetime.now(),
'title': 'title',
})
# update
comment = {
'commentor': DBRef(UserDocument.meta['collection'], alice_id),
'contents': 'I am comments.'
}
yield PostDocument.update({'_id': post_id},
{'$push': {'comments': comment}})
# query
user = yield UserDocument.find_one({'name': 'Bob'})
posts = yield PostDocument.find().to_list(5)
# higher API
user_list = yield UserDocument.get_user_list()
Documentation
You will need sphinx installed to generate the documentation. Documentation can be generated by running python setup.py doc. Generated documentation can be found in doc/build/html/. You can read the current docs at ReadTheDocs.
Metadata
Release files for monguo 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| monguo-0.2.2.tar.gz | 14.4 kB | Without provenance | Details for monguo-0.2.2.tar.gz |
Release files / monguo-0.2.2.tar.gz
| Download URL | monguo-0.2.2.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7225a809aea49da46319df0837fd75e3232d92f60e51f1fef21ae046df1bfbe
|
|
BLAKE2b-256 checksum How to use checksums |
4c7111b550b43d5a585d0a63644c151cd12f740cf4e3047603ecf380a2a336ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for monguo 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.