K.E.V. (键、附加项和值)是基于 Valley 的键值存储的 Python ORM。目前支持的后端包括 Redis、S3 和 S3/Redis 混合后端。
K.E.V. (键、附加项和值)是基于 Valley 的键值存储的 Python ORM。目前支持的后端包括 Redis、S3 和 S3/Redis 混合后端。
K.E.V. (Keys, Extra Stuff, and Values) is a Python ORM for key-value stores and document databases based on Valley. Currently supported backends are Redis, S3 and a S3/Redis hybrid backend.
Kev should work on Python 3.5+ and higher
pip install kevExample: loading.py
…Example: models.py
…>>>from .models import TestDocument
>>>kevin = TestDocument(name='Kev',is_active=True,no_subscriptions=3,state='NC',gpa=3.25)
>>>kevin.save()
>>>kevin.name
'Kev'
>>>kevin.is_active
True
>>>kevin.pk
ec640abfd6
>>>kevin.id
ec640abfd6
>>>kevin._id
'ec640abfd6:id:s3redis:testdocument'
>>>george = TestDocument(name='George',is_active=True,no_subscriptions=3,gpa=3.25,state='VA')
>>>george.save()
>>>sally = TestDocument(name='Sally',is_active=False,no_subscriptions=6,gpa=3.0,state='VA')
>>>sally.save()>>>TestDocument.objects().all()
[,,]
>>>TestDocument.objects().all(skip=1)
[,]
>>>TestDocument.objects().all(limit=2)
[,]
>>>TestDocument.get('ec640abfd6')
>>>TestDocument.objects().get({'state':'NC'})
>>>TestDocument.objects().filter({'state':'VA'})
[,]
>>>TestDocument.objects().filter({'no_subscriptions':3})
[,]
>>>TestDocument.objects().filter({'no_subscriptions':3,'state':'NC'})
[]>>>TestDocument.objects().filter({'no_subscriptions':3}).sort_by('name')
[, ]
>>>TestDocument.objects().filter({'no_subscriptions':3}).sort_by('name', reverse=True)
[, ]
>>>TestDocument.objects().all().sort_by('gpa')
[, , ]
TestDocument.objects().all().sort_by('name').sort_by('gpa')
[, >, >>TestDocument.objects().filter({'no_subscriptions':3}).filter({'state':'NC'})
[]
Wildcard filters currently only work with the Redis and S3/Redis backend. Use prefixes with the S3 backend.
>>>TestDocument.objects().filter({'state':'N*'})
[]
Prefix filters currently only work with the S3 backend. Use wildcard filters with the Redis or S3/Redis backends.
>>>TestDocument.objects().filter({'state':'N'})
[]Easily backup or restore your model locally or from S3. The backup method creates a JSON file backup.
TestDocument().backup('test-backup.json')
TestDocument().backup('s3://your-bucket/kev/test-backup.json')
TestDocument().restore('test-backup.json')
TestDocument().restore('s3://your-bucket/kev/test-backup.json')Twitter::@brianjinwright Github: bjinwright
暂无开放 Issues,或尚未同步最近议题。