Public Member Functions | |
| def | __init__ |
| def | __del__ |
| def | __repr__ |
| def | __getattr__ |
| def | __getitem__ |
| def | get_collection |
| def | create_collection |
| def | drop_collection |
| def | rename_collection |
| def | get_collection_names |
| def | get_collection_space_name |
| def | alter |
| def | set_domain |
| def | remove_domain |
| def | get_domain_name |
| def | enable_capped |
| def | disable_capped |
| def | set_attributes |
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.alter | ( | self, | |
| options | |||
| ) |
Alter the current collection space.
Parameters:
Name Type Info:
options dict The options for alter collection space, including
Domain : domain of collection space
PageSize : page size of collection space
LobPageSize : LOB page size of collection space
| 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 are as following:
ShardingKey : Assign the sharding key, foramt: { ShardingKey: { <key name>: <1/-1>} },
1 indicates positive order, -1 indicates reverse order.
e.g. { ShardingKey: { age: 1 } }
ShardingType : Assign the sharding type, default is "hash"
Partition : The number of partition, it is valid when ShardingType is "hash",
the range is [2^3, 2^20], default is 4096
ReplSize : Assign how many replica nodes need to be synchronized when a write
request (insert, update, etc) is executed, default is 1
Compressed : Whether to enable data compression, default is true
CompressionType : The compression type of data, could be "snappy" or "lzw", default is "lzw"
AutoSplit : Whether to enable the automatic partitioning, it is valid when ShardingType
is "hash", defalut is false
Group : Assign the data group to which it belongs, default: The collection will
be created in any data group of the domain that the collection belongs to
AutoIndexId : Whether to build "$id" index, default is true
EnsureShardingIndex : Whether to build sharding index, default is true
StrictDataMode : Whether to enable strict date mode in numeric operations, default is false
AutoIncrement : Assign attributes of an autoincrement field or batch autoincrement fields
e.g. { AutoIncrement : { Field : "a", MaxValue : 2000 } },
{ AutoIncrement : [ { Field : "a", MaxValue : 2000}, { Field : "a", MaxValue : 4000 } ] }
LobShardingKeyFormat : Assign the format of lob sharding key, could be "YYYYMMDD", "YYYYMM" or "YYYY".
It is valid when the collection is main collection
IsMainCL : Main collection or not, default is false, which means it is not main collection
DataSource : The name of the date soure used
Mapping : The name of the collection to be mapped
Return values:
a collection object created
Exceptions:
pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.disable_capped | ( | self | ) |
Alter the current collection space to disble capped.
| 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.enable_capped | ( | self | ) |
Alter the current collection space to enable capped.
| def pysequoiadb.collectionspace.collectionspace.get_collection | ( | self, | |
| cl_name | |||
| ) |
Get the named collection. Parameters: Name Type Info: cl_name str The short name of the collection. Return values: a collection object of query Exceptions: pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.get_collection_names | ( | self | ) |
Get the names of all collections in the current collection space. Return values: A list of collection names Exceptions: 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
| def pysequoiadb.collectionspace.collectionspace.get_domain_name | ( | self | ) |
Get the Domain name of the current collection space. Returns an empty string if the current collection space Return values: The domain name of the current collection space. Exceptions: pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.remove_domain | ( | self | ) |
Alter the current collection space to remove domain.
| def pysequoiadb.collectionspace.collectionspace.rename_collection | ( | self, | |
| old_name, | |||
| new_name, | |||
options = None |
|||
| ) |
Rename the specified collection in current collection space. Parameters: Name Type Info: old_name str The original name of collection. new_name str The new name of collection. options dict Options for renaming. Exceptions: pysequoiadb.error.SDBTypeError pysequoiadb.error.SDBBaseError
| def pysequoiadb.collectionspace.collectionspace.set_attributes | ( | self, | |
| options | |||
| ) |
Alter the current collection space.
Parameters:
Name Type Info:
options dict The options for alter collection space, including
Domain : domain of collection space
PageSize : page size of collection space
LobPageSize : LOB page size of collection space
| def pysequoiadb.collectionspace.collectionspace.set_domain | ( | self, | |
| options | |||
| ) |
Alter the current collection space to set domain.
Parameters:
Name Type Info:
options dict The options for alter collection space, including
Domain : domain of collection space
1.8.2