Public Member Functions | |
| def | __init__ |
| def | __del__ |
| def | __repr__ |
| def | __getattr__ |
| def | __getitem__ |
| def | get_collection |
| def | create_collection |
| def | drop_collection |
| def | get_collection_space_name |
CollectionSpace for SequoiaDB
All operation need deal with the error code returned first, if it has.
Every error code is not SDB_OK(or 0), it means something error has appeared,
and user should deal with it according the meaning of error code printed.
@version: execute to get version
>>> import pysequoiadb
>>> print pysequoiadb.get_version()
@notice : The dict of built-in Python is hashed and non-ordered. so the
element in dict may not the order we make it. we make a dict and
print it like this:
...
>>> a = {"avg_age":24, "major":"computer science"}
>>> a
>>> {'major': 'computer science', 'avg_age': 24}
...
the elements order it is not we make it!!
therefore, we use bson.SON to make the order-sensitive dict if the
order is important such as operations in "$sort", "$group",
"split_by_condition", "aggregate","create_collection"...
In every scene which the order is important, please make it using
bson.SON and list. It is a subclass of built-in dict
and order-sensitive
| def pysequoiadb.collectionspace.collectionspace.__init__ | ( | self | ) |
invoked when a new object is producted. Exceptions: pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.__del__ | ( | self | ) |
delete a object existed. Exceptions: pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.__getattr__ | ( | self, | |
| name | |||
| ) |
support client.cs to access to collection.
eg.
cc = client()
cs = cc.test
cl = cs.test_cl # access to collection named 'test_cl'
and we should pass '__members__' and '__methods__',
becasue dir(cc) will invoke __getattr__("__members__") and
__getattr__("__methods__").
if success, a collection object will be returned.
Exceptions:
pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.__getitem__ | ( | self, | |
| name | |||
| ) |
support [] to access to collection. eg. cc = client() cs = cc['test'] cl = cs['test_cl'] # access to collection named 'test_cl'. Exceptions: pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.create_collection | ( | self, | |
| cl_name, | |||
options = None |
|||
| ) |
create a collection using name and options.
Parameters:
Name Type Info:
cl_name str The collection name.
options dict The options for creating collection, including
"ShardingKey", "ReplSize", "IsMainCL" and
"Compressed" informations, no options, if None.
Return values:
a collection object created
Exceptions:
pysequoiadb.error.SDBTypeError
pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.drop_collection | ( | self, | |
| cl_name | |||
| ) |
Drop the specified collection in current collection space. Parameters: Name Type Info: cl_name str The collection name. Exceptions: pysequoiadb.error.SDBTypeError pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.get_collection | ( | self, | |
| cl_name | |||
| ) |
Get the named collection. Parameters: Name Type Info: cl_name str The full name of the collection.. Return values: a collection object of query Exceptions: pysequoiadb.error.SDBTypeError pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.get_collection_space_name | ( | self | ) |
Get the current collection space name. Return values: The name of current collection space. Exceptions: pysequoiadb.error.SDBBaseError
1.8.2