easyeasy.io云数据库客户端
easyeas的Python项目详细描述
易用。客户端
如何使用
安装
pip install easyeasy
初始化
fromeasyeasy.clientimportClientclient=Client("bc420813-17d9-47fa-9d29-8bd6a1207f8a")
示例
classCat:def__init__(self):self.id=Noneself.name=Noneself.interests=[]self.age=Nonecat=Cat()cat.name="Sam"cat.age=1.5cat.interests=["play","eat","discover"]# add object. entity name will be inferred from class nameid=client.add(cat)# or specify entity name explicitlyid=client.add(cat,"cat")# get one object by id. Specify entity type. Entity name will be inferredcat=client.get_one(id,Cat)# or specify entity name explicitlycat=client.get_one(id,Cat,"cat")# at least one should be specified(entity_class or entity_name). In case entity_class not specified, dict object will be returned# update objectcat.age=2.0cat.interests=["eat","sleep","play"]# object must have id property to distinguish which object is being updated. entity_name can be specified explicitlyclient.update(cat)# get all objects. entity_name can be specified explicitlycats_collection=client.get(Cat)# filteringcats_collection=client.get(Cat,query={'age':1.5})# get 1.5 years old catscats_collection=client.get(Cat,query={'age_gt':1.0})# cats older than 1 yearcats_collection=client.get(Cat,query={"name_like":"Sa*"})# wildcard# pagingcats_collection=client.get(Cat,query={"_start":"10","_count":10})# orderingcats_collection=client.get(Cat,query={"_orderby":"age"})cats_collection=client.get(Cat,query={"_orderbydesc":"age"})# learn more about filtering operators at: http://easyeasy.io/docs#/operators# delete object by idclient.delete(cat.id,Cat)
许可证
ISC