Skip to main content

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)



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


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.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

nosqlalchemy-0.9.2-py2.7.egg (15.8 kB view details)

Uploaded Source

File details

Details for the file nosqlalchemy-0.9.2.tar.gz.

File metadata

File hashes

Hashes for nosqlalchemy-0.9.2.tar.gz
Algorithm Hash digest
SHA256 590519d3e2d5133fc257183c0678891cb99ae8e458952ad71454329c241c2a37
MD5 ac81fc23d0936cf6ac16beae55c380b0
BLAKE2b-256 6348876dc1fc9403a2c40d520877b230aae0f1b803874a552acf0ea08f40b68a

See more details on using hashes here.

File details

Details for the file nosqlalchemy-0.9.2-py2.7.egg.

File metadata

File hashes

Hashes for nosqlalchemy-0.9.2-py2.7.egg
Algorithm Hash digest
SHA256 9508b6e3c34edd6b2f76b015e6aa2636b69f60d7c532c00f1c7dcb5cd949f1e7
MD5 41876cbd5ec4a9af15b12a1dba3e9136
BLAKE2b-256 61a876af350331b617d1b39003b2e5771e3d2af4284ccedafaf6ad61811c6f08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page