Skip to main content

Better ORM wrapper of leancloud storage python sdk.

Project description


PyPI version travis-ci codecov

better leancloud storage wrapper. Simple and lightweight.


install by easy_install or pip.

$ pip install leancloud-better-storage

Quick start

Model declaration and query just like SQLAlchemy, see example below.

Model declaration

from import Model
from import Field

class Product(Model):
    name = Field('product_name', nullable=False)
    price = Field(nullable=False)
    field3 = Field(nullable=False, default=1)
    field4 = Field()

CRUD operations


product = Product.create(name='FirstProduct',price=100)

# v0.1.3 now default null value
assert product.field4 is None

Read & Query

# find by simple equation
products = Product.query().filter_by(name='product').find()
# support >,<,>=,<=,==.but not support compare to another field.
products = Product.query().filter(Product.price < 10).find()
# support and_(), or_().
products = Product.query().filter(Product.created_at > datetime(2018,8,1)).and_() \
    .filter(Product.created_at < datetime(2018,9,1)).find()
# find support limit and skip argument.
products = Product.query().order_by(Product.price.desc).find(limit=10)
# also support pagination, start from page 0 and 10 elements per page.
pages = Product.query().paginate(0, 10)
for page in pages:
    print(page.items) # access elements


product = Product.query().filter_by(name='FirstProduct').first() = 'LastProduct'


product = Product.query().filter_by(name='FirstProduct').first()

Update log

  • 0.1.7 修复初始值 null 覆盖了存储服务生成字段值的问题。

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

leancloud-better-storage-0.1.7.tar.gz (6.3 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page