{ "info": { "author": "Stephen Chapman, Jason Jones", "author_email": "schapman1974@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "\n.. image:: http://198.27.119.65/tinymongo.png\n :target: http://198.27.119.65/tinymongo.png\n :alt: logo\n\n\n\n.. image:: https://travis-ci.org/jjonesAtMoog/tinymongo.svg?branch=master\n :target: https://travis-ci.org/jjonesAtMoog/tinymongo\n :alt: Build Status\n\n\nPurpose\n=======\n\nA simple wrapper to make a drop in replacement for mongodb out of\n`tinydb `_. This module is an\nattempt to add an interface familiar to those currently using pymongo.\n\nStatus\n======\n\nUnit testing is currently being worked on and functionality is being\nadded to the library. Current coverage is 93%. Current builds tested\non Python versions 2.7 and 3.3+.\n\nInstallation\n============\n\nThe latest stable release can be installed via ``pip install tinymongo``.\n\nThe library is currently under rapid development and a more recent version\nmay be desired.\n\nIn this case, simply clone this repository, navigate\nto the root project directory, and ``pip install -e .``\n\nor use ``pip install -e git+https://github.com/schapman1974/tinymongo.git#egg=tinymongo``\n\nThis\nis a pure python distribution and - thus - should require no external\ncompilers or tools besides those contained within Python itself.\n\nExamples\n========\n\nThe quick start is shown below. For a more detailed look at tinymongo,\ntake a look at demo.py within the repository.\n\n.. code-block:: python\n\n from tinymongo import TinyMongoClient\n\n # you can include a folder name or absolute path\n # as a parameter if not it will default to \"tinydb\"\n connection = TinyMongoClient()\n\n # either creates a new database file or accesses an existing one named `my_tiny_database`\n db = connection.my_tiny_database\n\n # either creates a new collection or accesses an existing one named `users`\n collection = db.users\n\n # insert data adds a new record returns _id\n record_id = collection.insert_one({\"username\": \"admin\", \"password\": \"admin\", \"module\":\"somemodule\"}).inserted_id\n user_info = collection.find_one({\"_id\": record_id}) # returns the record inserted\n\n # you can also use it directly\n db.users.insert_one({\"username\": \"admin\"})\n\n # returns a list of all users of 'module'\n users = db.users.find({'module': 'module'})\n\n #update data returns True if successful and False if unsuccessful\n upd = db.users.update_one({\"username\": \"admin\"}, {\"$set\": {\"module\":\"someothermodule\"}})\n\n # Sorting users by its username DESC\n # omitting `filter` returns all records\n db.users.find(sort={'username': -1})\n\n # Pagination of the results\n # Getting the first 20 records\n db.users.find(sort={'username': -1}, skip=0, limit=20)\n # Getting next 20 records\n db.users.find(sort={'username': -1}, skip=20, limit=20)\n\n # Getting the total of records\n db.users.count()\n\nCustom Storages and Serializers\n===============================\n\n..\n\n HINT: Learn more about TinyDB storages and Serializers in `documentation `_\n\n\nCustom Storages\n---------------\n\nYou have to subclass ``TinyMongoClient`` and provide custom storages like\nCachingMiddleware or other available TinyDB Extension.\n\nCaching Middleware\n^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from tinymongo import TinyMongoClient\n from tinydb.storages import JSONStorage\n from tinydb.middlewares import CachingMiddleware\n\n class CachedClient(TinyMongoClient):\n \"\"\"This client has cache\"\"\"\n @property\n def _storage(self):\n return CachingMiddleware(JSONStorage)\n\n connection = CachedClient('/path/to/folder')\n\n..\n\n HINT: You can nest middlewares: ``FirstMiddleware(SecondMiddleware(JSONStorage))``\n\n\nSerializers\n-----------\n\nTo convert your data to a format that is writable to disk TinyDB uses the Python JSON module by default. It's great when only simple data types are involved but it cannot handle more complex data types like custom classes.\n\nTo support serialization of complex types you can write\nyour own serializers using the ``tinydb-serialization`` extension.\n\nFirst you need to install it ``pip install tinydb-serialization``\n\nHandling datetime objects\n-------------------------\n\nYou can create a serializer for the python ``datetime`` using\nthe following snippet:\n\n.. code-block:: python\n\n from datetime import datetime\n from tinydb_serialization import Serializer\n\n class DatetimeSerializer(Serializer):\n OBJ_CLASS = datetime\n\n def __init__(self, format='%Y-%m-%dT%H:%M:%S', *args, **kwargs):\n super(DatetimeSerializer, self).__init__(*args, **kwargs)\n self._format = format\n\n def encode(self, obj):\n return obj.strftime(self._format)\n\n def decode(self, s):\n return datetime.strptime(s, self._format)\n\n..\n\n NOTE: this serializer is available in ``tinymongo.serializers.DateTimeSerializer``\n\n\nNow you have to subclass ``TinyMongoClient`` and provide customs storage.\n\n.. code-block:: python\n\n from tinymongo import TinyMongoClient\n from tinymongo.serializers import DateTimeSerializer\n from tinydb_serialization import SerializationMiddleware\n\n\n class CustomClient(TinyMongoClient):\n @property\n def _storage(self):\n serialization = SerializationMiddleware()\n serialization.register_serializer(DateTimeSerializer(), 'TinyDate')\n # register other custom serializers\n return serialization\n\n\n connection = CustomClient('/path/to/folder')\n\nFlask-Admin\n===========\n\nThis extension can work with Flask-Admin which gives a web based administrative\npanel to your TinyDB. Flask-Admin has features like filtering, search, web forms to\nperform CRUD (Create, Read, Update, Delete) of the TinyDB records.\n\nYou can find the example of Flask-Admin with TinyMongo in `Flask-Admin Examples Repository `_\n\n..\n\n NOTE: To use Flask-Admin you need to register a DateTimeSerialization as showed in the previous topic.\n\n\nContributions\n=============\n\nContributions are welcome! Currently, the most valuable contributions\nwould be:\n\n\n* adding test cases\n* adding functionality consistent with pymongo\n* documentation\n* identifying bugs and issues\n\nFuture Development\n==================\n\nI will also be adding support for gridFS by storing the files somehow and indexing them in a db like mongo currently does\n\nMore to come......\n\nLicense\n=======\n\nMIT License\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/schapman1974/tinymongo/archive/master.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/schapman1974/tinymongo", "keywords": "mongodb,drop-in,database,tinydb", "license": "", "maintainer": "", "maintainer_email": "", "name": "tinymongo", "package_url": "https://pypi.org/project/tinymongo/", "platform": "", "project_url": "https://pypi.org/project/tinymongo/", "project_urls": { "Download": "https://github.com/schapman1974/tinymongo/archive/master.zip", "Homepage": "https://github.com/schapman1974/tinymongo" }, "release_url": "https://pypi.org/project/tinymongo/0.2.0/", "requires_dist": [ "tinydb (>=3.2.1)", "tinydb-serialization (>=1.0.4)" ], "requires_python": "", "summary": "A flat file drop in replacement for mongodb. Requires Tinydb", "version": "0.2.0" }, "last_serial": 3243046, "releases": { "0.1.3.dev0": [], "0.1.7.dev0": [ { "comment_text": "", "digests": { "md5": "4d5c68dc244abe270756482518caa26e", "sha256": "c392a55351ad325bbbfab754ec5f11409a6ff6743a83e2160daa68545fa45af3" }, "downloads": -1, "filename": "tinymongo-0.1.7.dev0.tar.gz", "has_sig": false, "md5_digest": "4d5c68dc244abe270756482518caa26e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9267, "upload_time": "2017-03-17T18:04:21", "url": "https://files.pythonhosted.org/packages/0b/22/1f2bfb9d1a10f57458149d86c87d79beecaad12293010ac25912adbab00a/tinymongo-0.1.7.dev0.tar.gz" } ], "0.1.8.dev0": [ { "comment_text": "", "digests": { "md5": "708b4f601da176a3b8b0db3d3c0c0da1", "sha256": "6b34fe40bc4c119638219298a39528f0f43216b1e8a102ee32bf10dec409d0b4" }, "downloads": -1, "filename": "tinymongo-0.1.8.dev0.tar.gz", "has_sig": false, "md5_digest": "708b4f601da176a3b8b0db3d3c0c0da1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12174, "upload_time": "2017-04-19T19:47:10", "url": "https://files.pythonhosted.org/packages/74/fd/048be0664cc75adbef9a486bdcf03c9c5a93c0c5b2d229414856199b800b/tinymongo-0.1.8.dev0.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "7a5d41cdb9ec7c44369fec19ec9f0342", "sha256": "1559021f367a3ab14c66d10ead003b58515da20ed1732994f357d14e39a07b85" }, "downloads": -1, "filename": "tinymongo-0.1.9.tar.gz", "has_sig": false, "md5_digest": "7a5d41cdb9ec7c44369fec19ec9f0342", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12314, "upload_time": "2017-06-15T12:25:12", "url": "https://files.pythonhosted.org/packages/e2/1c/39f4c5689daaf9ca0682225630a20fa35a79562ed91d459354079e9778ce/tinymongo-0.1.9.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1424e71fbf01ffcbabc9fdc815bb9ebb", "sha256": "1bbbb8784386ea0ab079cab66b6b182390d9c825ca33b1abce4a375cccb828cf" }, "downloads": -1, "filename": "tinymongo-0.2.0-py2-none-any.whl", "has_sig": false, "md5_digest": "1424e71fbf01ffcbabc9fdc815bb9ebb", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 13875, "upload_time": "2017-10-11T18:44:30", "url": "https://files.pythonhosted.org/packages/b5/8b/bd6cba585f6c7d02bb83e31eb0cc61f7ab5b159963ff9de5015a558dbed7/tinymongo-0.2.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd012b209a9099a16c280aba1f017013", "sha256": "733de042ec6fcaf2630bfd76761be1c084f503ceff1c05621c7be47481d86ba3" }, "downloads": -1, "filename": "tinymongo-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fd012b209a9099a16c280aba1f017013", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12653, "upload_time": "2017-10-11T18:44:31", "url": "https://files.pythonhosted.org/packages/a6/37/a44a36381c30ecdbba6adc435c4e2e0bb387b5907c45f92da03e7a81c261/tinymongo-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1424e71fbf01ffcbabc9fdc815bb9ebb", "sha256": "1bbbb8784386ea0ab079cab66b6b182390d9c825ca33b1abce4a375cccb828cf" }, "downloads": -1, "filename": "tinymongo-0.2.0-py2-none-any.whl", "has_sig": false, "md5_digest": "1424e71fbf01ffcbabc9fdc815bb9ebb", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 13875, "upload_time": "2017-10-11T18:44:30", "url": "https://files.pythonhosted.org/packages/b5/8b/bd6cba585f6c7d02bb83e31eb0cc61f7ab5b159963ff9de5015a558dbed7/tinymongo-0.2.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd012b209a9099a16c280aba1f017013", "sha256": "733de042ec6fcaf2630bfd76761be1c084f503ceff1c05621c7be47481d86ba3" }, "downloads": -1, "filename": "tinymongo-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fd012b209a9099a16c280aba1f017013", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12653, "upload_time": "2017-10-11T18:44:31", "url": "https://files.pythonhosted.org/packages/a6/37/a44a36381c30ecdbba6adc435c4e2e0bb387b5907c45f92da03e7a81c261/tinymongo-0.2.0.tar.gz" } ] }