Better ORM wrapper of leancloud storage python sdk.
Project description
leancloud-better-storage-python
better leancloud storage wrapper. Simple and lightweight.
Installation
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 leancloud_better_storage.storage.models import Model
from leancloud_better_storage.storage.fields import Field
class Product(Model):
name = Field('product_name', nullable=False)
price = Field(nullable=False)
field3 = Field(nullable=False, default=1)
CRUD operations
Create
product = Product.create(name='FirstProduct',price=100)
product.commit()
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
Update
product = Product.query().filter_by(name='FirstProduct').first()
product.name = 'LastProduct'
product.commit()
Delete
product = Product.query().filter_by(name='FirstProduct').first()
product.drop()
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
Built Distribution
Close
Hashes for leancloud-better-storage-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d186caaeac44254dccb51b1dc95dc6f70abc064de360229503bf10f8a34b0f5 |
|
MD5 | 0bc18d48518e21d8dc564014a8d8b892 |
|
BLAKE2b-256 | 7340105c0bc86688e5da061525e589d630c195c7cc59cd33ec9412964cda910a |
Close
Hashes for leancloud_better_storage-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef90574fdb3c777db663ea9ae7904d62917f5bd98164026018fb952e0a18bc59 |
|
MD5 | af335f4fcdf2aa5dbf8d9961e158df79 |
|
BLAKE2b-256 | 2c281b2c75a8b4f9939b8ac1b33f3eb41e5178f55061be6e5c06d1588ce957e0 |