Define loosly ordered schema for mongodb documents.
Project description
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%
commit ed63d179cbabd504714072d5a9928aea3a5e62d0
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Thu Aug 1 00:37:24 2013 -0500
LazyCollection fixes
commit 11319759a2888d1a0c75d0d568fe214c32b79d8a
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Mon Jul 29 17:42:38 2013 -0500
Adding LazyCollections test
commit dc69acfc910d10c8677121993a8ad1912ea7ff07
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Mon Jul 29 17:42:16 2013 -0500
Adding LazyCollections
commit 5f6b5a2b22be3f9d67dfa23fac39c0e8f843fce5
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue Jul 9 15:48:34 2013 -0500
fix class variable collisions
commit 17d0d5cb59388bfad5a6f9bdb0aceb35eb78d3ad
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue Jul 9 15:47:51 2013 -0500
Reverse order of refernce for more robust testing
commit 9de5592e07196102ccbbff3f5c149ed601417f11
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Fri Jun 14 18:50:16 2013 -0500
instansiate empty subcollections and listcollections on init
commit 85a64eb869ab6006c8c1c22caff7bbd81997b5cf
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Fri Jun 14 17:55:19 2013 -0500
return the oid on save
commit 567d66c16bec355128f607857e0f9cbafb12a183
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Fri Jun 14 14:46:20 2013 -0500
add remove() method to query object for bulk removal
commit 9bdc3c0e57d1b277bb5a2af84cc4fd3585ed385e
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue May 28 09:32:52 2013 -0500
Update changelog
commit 3f0fdfc871e3fd55e57999e45567bdb372c0bc8c
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue May 28 09:32:01 2013 -0500
remove unneeded assignment
commit a9328a037100e095eea14c376f004d6558191bc7
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue May 28 09:28:05 2013 -0500
Changes
commit 82bab92adebcb452b832a1166990602d8d65d47e
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Sun May 26 14:45:43 2013 -0500
Creating a python package and adding tests
Added SubCollection and ListCollection support
commit 259a066cfcb974984c959c26bd0f6ea5139f8343
Author: Jared Rodriguez <jrod@blacknode.net>
Date: Fri Jan 6 18:16:01 2012 -0600
fux0rs
commit 67e6a57f3a123aacabf1ced020ab1a5606aa69bf
Author: Jared Rodriguez <jrod@blacknode.net>
Date: Thu Dec 15 21:10:42 2011 -0600
first commit
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%
commit ed63d179cbabd504714072d5a9928aea3a5e62d0
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Thu Aug 1 00:37:24 2013 -0500
LazyCollection fixes
commit 11319759a2888d1a0c75d0d568fe214c32b79d8a
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Mon Jul 29 17:42:38 2013 -0500
Adding LazyCollections test
commit dc69acfc910d10c8677121993a8ad1912ea7ff07
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Mon Jul 29 17:42:16 2013 -0500
Adding LazyCollections
commit 5f6b5a2b22be3f9d67dfa23fac39c0e8f843fce5
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue Jul 9 15:48:34 2013 -0500
fix class variable collisions
commit 17d0d5cb59388bfad5a6f9bdb0aceb35eb78d3ad
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue Jul 9 15:47:51 2013 -0500
Reverse order of refernce for more robust testing
commit 9de5592e07196102ccbbff3f5c149ed601417f11
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Fri Jun 14 18:50:16 2013 -0500
instansiate empty subcollections and listcollections on init
commit 85a64eb869ab6006c8c1c22caff7bbd81997b5cf
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Fri Jun 14 17:55:19 2013 -0500
return the oid on save
commit 567d66c16bec355128f607857e0f9cbafb12a183
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Fri Jun 14 14:46:20 2013 -0500
add remove() method to query object for bulk removal
commit 9bdc3c0e57d1b277bb5a2af84cc4fd3585ed385e
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue May 28 09:32:52 2013 -0500
Update changelog
commit 3f0fdfc871e3fd55e57999e45567bdb372c0bc8c
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue May 28 09:32:01 2013 -0500
remove unneeded assignment
commit a9328a037100e095eea14c376f004d6558191bc7
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Tue May 28 09:28:05 2013 -0500
Changes
commit 82bab92adebcb452b832a1166990602d8d65d47e
Author: Jared Rodriguez <jared.rodriguez@rackspace.com>
Date: Sun May 26 14:45:43 2013 -0500
Creating a python package and adding tests
Added SubCollection and ListCollection support
commit 259a066cfcb974984c959c26bd0f6ea5139f8343
Author: Jared Rodriguez <jrod@blacknode.net>
Date: Fri Jan 6 18:16:01 2012 -0600
fux0rs
commit 67e6a57f3a123aacabf1ced020ab1a5606aa69bf
Author: Jared Rodriguez <jrod@blacknode.net>
Date: Thu Dec 15 21:10:42 2011 -0600
first commit
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nosqlalchemy-0.9.6.tar.gz
(7.4 kB
view details)
File details
Details for the file nosqlalchemy-0.9.6.tar.gz
.
File metadata
- Download URL: nosqlalchemy-0.9.6.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2398289af77b199005c91e8b68ff983b8cd54457c00ed21ee03939818d52b1 |
|
MD5 | ed08c97a84504301ecc171f654ed0545 |
|
BLAKE2b-256 | 3a2cfac0e03165637b4fc5db45f2a3eb486f9d5c593c8e58637547fc7f1f9561 |