A simple wrapper to make a drop in replacement for mongodb out of tinydb. This module is an attempt to add an interface familiar to those currently using pymongo.
Unit testing is currently being worked on and functionality is being added to the library. Current coverage is 93%. Current builds tested on Python versions 2.7 and 3.3+.
The latest release can be installed via pip install tinymongo
. The
library is currently under rapid development and a more recent version
may be desired. In this case, simply clone this repository, navigate
to the root project directory, and python setup.py install
. This
is a pure python distribution and - thus - should require no external
compilers or tools besides those contained within Python itself.
The quick start is shown below. For a more detailed look at tinymongo, take a look at demo.py within the repository.
from tinymongo import *
# you can include a folder name as a parameter if not it will default to "tinydb"
tinyClient = TinyMongoClient()
# either creates a new database file or accesses an existing one
tinyDatabase = tinyClient.tinyDatabase
# either creates a new collection or accesses an existing one
tinyCollection = tinyDatabase.tinyCollection
# insert data adds a new record returns _id
recordId = tinyCollection.insert_one({"username": "admin", "password": "admin", "module":"somemodule"})
userInfo = tinyCollection.find_one({"_id":recordId}) # returns the record inserted
# returns a list of all users of 'module'
users = tinyCollection.find({'module': 'module'})
#update data returns True if successful and False if unsuccessful
upd = table.update_one({"username": "admin"}, {"$set": {"module":"someothermodule"}})
Contributions are welcome! Currently, the most valuable contributions would be:
- adding test cases
- adding functionality consistent with pymongo
- documentation
- identifying bugs and issues
I will also be adding support for gridFS by storing the files somehow and indexing them in a db like mongo currently does
More to come......
MIT License