Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slacy/minimongo
A lightweight, Pythonic, Object Oriented Interface to MongoDB.
https://github.com/slacy/minimongo
Last synced: 9 days ago
JSON representation
A lightweight, Pythonic, Object Oriented Interface to MongoDB.
- Host: GitHub
- URL: https://github.com/slacy/minimongo
- Owner: slacy
- License: bsd-2-clause
- Created: 2010-12-21T07:04:07.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2020-01-28T15:38:15.000Z (almost 5 years ago)
- Last Synced: 2024-09-23T02:08:18.424Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 281 KB
- Stars: 332
- Watchers: 16
- Forks: 52
- Open Issues: 16
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.txt
- License: LICENSE
Awesome Lists containing this project
- awesome-mongodb - minimongo - A lightweight, schemaless, Pythonic Object-Oriented interface (Libraries / Python)
- awesome-mongodb - minimongo - A lightweight, schemaless, Pythonic Object-Oriented interface (Libraries / Python)
README
minimongo
=========:Info: Minimal database Model management for MongoDB.
:Author: Steve Lacy ([email protected])About
-----``minimongo`` is a lightweight, schemaless, Pythonic Object-Oriented
interface to MongoDB.It provides a very thin, dynamicly typed (schema-less) object management
layer for any data stored in any MongoDB collection. ``minimongo`` directly
calls the existing pymongo_ query syntax.``minimongo`` can easily layer on top of existing MongoDB collections, and
will work properly with almost any existing schema, even from third party
applications.Installation
------------If you have `setuptools `_
you can use ``easy_install -U minimongo``. Otherwise, you can download the
source from `GitHub `_ and run ``python
setup.py install``.Dependencies
============
- pymongo_ 1.9+
- `sphinx `_ (optional -- for documentation generation)Example
-------Here's a very brief example of creating an object, querying for it, modifying
a field, and then saving it back again:.. code:: python
from minimongo import Model, Index
class Foo(Model):
class Meta:
# Here, we specify the database and collection names.
# A connection to your DB is automatically created.
database = "minimongo"
collection = "rocks"# Now, we programatically declare what indices we want.
# The arguments to the Index constructor are identical to
# the args to pymongo"s ensure_index function.
indices = (
Index("a"),
)if __name__ == "__main__":
# Create & save an object, and return a local in-memory copy of it:
foo = Foo({"x": 1, "y": 2}).save()# Find that object again, loading it into memory:
foo = Foo.collection.find_one({"x": 1})# Change a field value, and save it back to the DB.
foo.other = "some data"
foo.save()Feedback welcome!
-----------------Please email [email protected] with comments, suggestions, or comment via
http://github.com/slacy/minimongo.. _pymongo: http://api.mongodb.org/python/1.9%2B/index.html