{"id":13771173,"url":"https://github.com/capless/kev","last_synced_at":"2025-05-11T03:33:06.619Z","repository":{"id":9627257,"uuid":"62815321","full_name":"capless/kev","owner":"capless","description":"K.E.V. (Keys, Extras, and Values) is a Python ORM for key-value stores based on Valley. Currently supported backends are Redis, S3, and a S3/Redis hybrid backend. Based on Valley.","archived":false,"fork":false,"pushed_at":"2022-09-20T23:52:32.000Z","size":402,"stargazers_count":99,"open_issues_count":15,"forks_count":13,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-17T06:40:36.937Z","etag":null,"topics":["orm","redis","s3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/capless.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-07T14:56:35.000Z","updated_at":"2024-07-28T20:03:06.000Z","dependencies_parsed_at":"2023-01-11T17:39:44.951Z","dependency_job_id":null,"html_url":"https://github.com/capless/kev","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capless%2Fkev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capless%2Fkev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capless%2Fkev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capless%2Fkev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/capless","download_url":"https://codeload.github.com/capless/kev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514352,"owners_count":21920327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["orm","redis","s3"],"created_at":"2024-08-03T17:00:48.618Z","updated_at":"2025-05-11T03:33:06.354Z","avatar_url":"https://github.com/capless.png","language":"Python","readme":"![alt text](https://s3.amazonaws.com/capless/images/kev-small.png \"KEV - Keys, Extra Stuff, and Values\")\n\n\n# kev\nK.E.V. (Keys, Extra Stuff, and Values) is a Python ORM for key-value stores and document databases based on [**Valley**](https://www.github.com/capless/valley). Currently supported backends are Redis, S3 and a S3/Redis hybrid backend.\n\n[![Build Status](https://github.com/capless/kev/workflows/Unittests/badge.svg?branch=master)](https://github.com/capless/kev/actions?query=workflow%3AUnittests+branch%3Amaster)\n\n## Python Versions\n\nKev should work on Python 3.5+ and higher\n\n## Install\n```\npip install kev\n```\n\n\n## Example Project Using KEV\n\n- [flask-capless-blog](https://github.com/capless/flask-capless-blog)\n## Example Usage\n\n### Setup the Connection\n**Example:** loading.py\n```python\nfrom kev.loading import KevHandler\n\n\nkev_handler = KevHandler({\n    's3':{\n        'backend':'kev.backends.s3.db.S3DB',\n        'connection':{\n            'bucket':'your-bucket-name'\n        }\n    },\n    's3redis':{\n        'backend':'kev.backends.s3redis.db.S3RedisDB',\n        'connection':{\n            'bucket':'your-bucket-name',\n            'indexer':{\n                'host':'your.redis.host.com',\n                'port':6379,\n            }\n        }\n    },\n    'redis': {\n        'backend': 'kev.backends.redis.db.RedisDB',\n        'connection': {\n            'host': 'your-redis-host.com',\n            'port': 6379,\n        }\n    },\n})\n```\n### Setup the Models\n**Example:** models.py\n```python\nfrom kev import (Document,CharProperty,DateTimeProperty,\n                 DateProperty,BooleanProperty,IntegerProperty,\n                 FloatProperty)\nfrom .loading import kev_handler\n\nclass TestDocument(Document):\n    name = CharProperty(required=True,unique=True,min_length=3,max_length=20)\n    last_updated = DateTimeProperty(auto_now=True)\n    date_created = DateProperty(auto_now_add=True)\n    is_active = BooleanProperty(default_value=True,index=True)\n    city = CharProperty(required=False,max_length=50)\n    state = CharProperty(required=True,index=True,max_length=50)\n    no_subscriptions = IntegerProperty(default_value=1,index=True,min_value=1,max_value=20)\n    gpa = FloatProperty()\n\n    def __unicode__(self):\n        return self.name\n        \n\n    class Meta:\n        use_db = 's3redis'\n        handler = kev_handler\n\n```\n\n### Use the model\n#### How to Save a Document\n```python\n\u003e\u003e\u003efrom .models import TestDocument\n\n\u003e\u003e\u003ekevin = TestDocument(name='Kev',is_active=True,no_subscriptions=3,state='NC',gpa=3.25)\n\n\u003e\u003e\u003ekevin.save()\n\n\u003e\u003e\u003ekevin.name\n'Kev'\n\n\u003e\u003e\u003ekevin.is_active\nTrue\n\n\u003e\u003e\u003ekevin.pk\nec640abfd6\n\n\u003e\u003e\u003ekevin.id\nec640abfd6\n\n\u003e\u003e\u003ekevin._id\n'ec640abfd6:id:s3redis:testdocument'\n```\n#### Query Documents\n\n##### First Save Some More Docs\n```python\n\n\u003e\u003e\u003egeorge = TestDocument(name='George',is_active=True,no_subscriptions=3,gpa=3.25,state='VA')\n\n\u003e\u003e\u003egeorge.save()\n\n\u003e\u003e\u003esally = TestDocument(name='Sally',is_active=False,no_subscriptions=6,gpa=3.0,state='VA')\n\n\u003e\u003e\u003esally.save()\n```\n##### Show all Documents\n```python\n\u003e\u003e\u003eTestDocument.objects().all()\n\n[\u003cTestDocument: Kev:ec640abfd6\u003e,\u003cTestDocument: George:aff7bcfb56\u003e,\u003cTestDocument: Sally:c38a77cfe4\u003e]\n\n\u003e\u003e\u003eTestDocument.objects().all(skip=1)\n\n[\u003cTestDocument: George:aff7bcfb56\u003e,\u003cTestDocument: Sally:c38a77cfe4\u003e]\n\n\u003e\u003e\u003eTestDocument.objects().all(limit=2)\n\n[\u003cTestDocument: Kev:ec640abfd6\u003e,\u003cTestDocument: George:aff7bcfb56\u003e]\n\n```\n##### Get One Document\n```python\n\u003e\u003e\u003eTestDocument.get('ec640abfd6')\n\u003cTestDocument: Kev:ec640abfd6\u003e\n\n\u003e\u003e\u003eTestDocument.objects().get({'state':'NC'})\n\u003cTestDocument: Kev:ec640abfd6\u003e\n\n```\n##### Filter Documents\n```python\n\u003e\u003e\u003eTestDocument.objects().filter({'state':'VA'})\n\n[\u003cTestDocument: George:aff7bcfb56\u003e,\u003cTestDocument: Sally:c38a77cfe4\u003e]\n\n\u003e\u003e\u003eTestDocument.objects().filter({'no_subscriptions':3})\n[\u003cTestDocument: Kev:ec640abfd6\u003e,\u003cTestDocument: George:aff7bcfb56\u003e]\n\n\u003e\u003e\u003eTestDocument.objects().filter({'no_subscriptions':3,'state':'NC'})\n[\u003cTestDocument: Kev:ec640abfd6\u003e]\n```\n\n##### Sort Documents\n```python\n\u003e\u003e\u003eTestDocument.objects().filter({'no_subscriptions':3}).sort_by('name')\n[\u003cTestDocument: George:aff7bcfb56\u003e, \u003cTestDocument: Kev:ec640abfd6\u003e]\n\u003e\u003e\u003eTestDocument.objects().filter({'no_subscriptions':3}).sort_by('name', reverse=True)\n[\u003cTestDocument: Kev:ec640abfd6\u003e, \u003cTestDocument: George:aff7bcfb56\u003e]\n\u003e\u003e\u003eTestDocument.objects().all().sort_by('gpa')\n[\u003cTestDocument: Sally:c38a77cfe4\u003e, \u003cTestDocument: Kev:ec640abfd6\u003e, \u003cTestDocument: George:aff7bcfb56\u003e]\nTestDocument.objects().all().sort_by('name').sort_by('gpa')\n[\u003cTestDocument: Sally:c38a77cfe4\u003e, \u003cTestDocument: George:aff7bcfb56\u003e\u003e, \u003cTestDocument: Kev:ec640abfd6]\n```\n##### Chain Filters\nThe chain filters feature is only available for Redis and S3/Redis backends.\n```python\n\u003e\u003e\u003eTestDocument.objects().filter({'no_subscriptions':3}).filter({'state':'NC'})\n[\u003cTestDocument: Kev:ec640abfd6\u003e]\n\n```\n\n##### Wildcard Filters\nWildcard filters currently only work with the Redis and S3/Redis backend. Use prefixes with the S3 backend.\n```python\n\u003e\u003e\u003eTestDocument.objects().filter({'state':'N*'})\n[\u003cTestDocument: Kev:ec640abfd6\u003e]\n\n```\n\n##### Prefix Filters\nPrefix filters currently only work with the S3 backend. Use wildcard filters with the Redis or S3/Redis backends.\n```python\n\u003e\u003e\u003eTestDocument.objects().filter({'state':'N'})\n[\u003cTestDocument: Kev:ec640abfd6\u003e]\n```\n\n### Backup and Restore\n\nEasily backup or restore your model locally or from S3. The backup method creates a JSON file backup. \n\n#### Backup \n\n##### Local Backup\n\n```python\nTestDocument().backup('test-backup.json')\n```\n\n##### S3 Backup\n\n```python\n\nTestDocument().backup('s3://your-bucket/kev/test-backup.json')\n```\n\n#### Restore\n\n##### Local Restore\n\n```python\n\nTestDocument().restore('test-backup.json')\n```\n\n#### S3 Restore\n\n```python\n\nTestDocument().restore('s3://your-bucket/kev/test-backup.json')\n```\n\n### Author\n\n**Twitter:**:[@brianjinwright](https://twitter.com/brianjinwright)\n**Github:** [bjinwright](https://github.com/bjinwright)\n","funding_links":[],"categories":["ODM, ORM, Active Record"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapless%2Fkev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapless%2Fkev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapless%2Fkev/lists"}