nosqlalchemy usage: from nosqlalchemy import ( Collection, Key, ListCollection, MongoDBInterface, MongoSession, SubCollection, ) class SampleSubCollection(SubCollection): __name__ = 'sample_sub_collection' sub_key1 = Key() sub_key2 = Key() class SampleListCollection(ListCollection): __name__ = 'sample_list_collection' __list_element_type__ = int # base collection is set to object # do not override to store any object type # in the list class SampleCollection(Collection): __name__ = 'sample' __database__ = 'test' __primary_key__ = 'key1' # declares a unique value as unique within the # collection. key1 = Key() key2 = Key() sub_collection = SampleSubCollection() list_collection = SampleListCollection() mdi = MongoDBInterface() # args host='host', port='27017' MSession = MongoSession(mdi) sample_collection = SampleCollection() sample_collection.key1 = 'key1' sample_collection.key2 = 2 sample_collection.sub_collection.sub_key1 = 'sub_key1' sample_collection.sub_collection.sub_key2 = 2 sample_collection.list_collection.append(1) sample_collection.list_collection = 2 print sample_collection print type(MSession.add(sample_collection)) col = MSession.query(SampleCollection).find_one({'sub_collection.sub_key2': 2}) print col MSession.drop_all(SampleCollection) Test: coverage run --include=nosqlalchemy/__init__.py,nosqlalchemy/nosql.py --omit=nosqlalchemy/tests setup.py test test_bulk_remove (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_lazy_collection (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_list_collection (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_mongo_create (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_mongo_get (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_mongo_misc (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_mongo_query (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_mongo_remove (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_mongo_update (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_object_id_property (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_raw_mdi (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_sub_collection (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok test_sub_collection_list (nosqlalchemy.tests.nosqlalchemy_test.TestNoSQL) ... ok ---------------------------------------------------------------------- Ran 13 tests in 0.039s OK coverage report -m Name Stmts Miss Cover Missing ----------------------------------------------------- nosqlalchemy/__init__ 1 0 100% nosqlalchemy/nosql 207 10 95% 44, 179-187, 278, 283, 304 ----------------------------------------------------- TOTAL 208 10 95%