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)
field4 = Field()
CRUD operations
Create
product = Product.create(name='FirstProduct',price=100)
product.commit()
# 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
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()
Update log
- 0.1.7 修复初始值 null 覆盖了存储服务生成字段值的问题。
Release files for leancloud-better-storage 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| leancloud-better-storage-0.1.7.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leancloud_better_storage-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.7 kB
Release files / leancloud-better-storage-0.1.7.tar.gz
| Download URL | leancloud-better-storage-0.1.7.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8471ebe1cba5e7fe68dec4366800b7844b2451aec96d2c6d3a62ca3be505c486
|
|
BLAKE2b-256 checksum How to use checksums |
d546dcd435d71a8960076caf21b792343f9c91ad654f47a157b91d6e91095bbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / leancloud_better_storage-0.1.7-py3-none-any.whl
| Download URL | leancloud_better_storage-0.1.7-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
874e37c7f93221bc5e76ce61c023de6aaec6a85a6e06b721da29361360ca066c
|
|
BLAKE2b-256 checksum How to use checksums |
1ef5df83e681a67a32226d135192697ab11c385d4648ba568ad118056b132d7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|