Softmotions/ejdb-python — pull request #4 by deddu (2014-01-22 21:20:51+00:00)
Title: added __exit__ and __enter__ to EJDB obj to use inside with constructs.

for the ones that are used to query mongodb inside **with** constructs
and miss to automatically close the DB.
(and to mimic more closely Mongo usage)

example:
```python
import pyejdb
def create(entries, collection='mycoll', dbname='mydb'):
'''
creates a new instance of ejdb with the content of a json file or with the list of dictionaries passed in entries.
'''
import json
with pyejdb.EJDB(dbname, pyejdb.DEFAULT_OPEN_MODE | pyejdb.JBOTRUNC) as db:
if isinstance(entries,str):
with open(entries,'r') as f:
entries = json.load(f)

for addme in entries:
db.save(collection,addme)

if __name__=="__main__":
import sys
create(sys.argv[1])
```