Skip to main content

ORM for Redis

Project description

|PyPI Version| |Build Status|

======
redis-astra
======

Redis-astra is Python light ORM for Redis

Example:

.. code:: python

import redis
from astra import models

db = redis.StrictRedis(host='127.0.0.1', decode_responses=True)

class SiteObject(models.Model):
database = db
name = models.CharHash()

class UserObject(models.Model):
database = db
name = models.CharHash()
login = models.CharHash()
site_id = models.ForeignKeyHash(to='SiteObject')
sites_list = models.List(to='SiteObject')
viewers = models.IntegerField()


So you can use it like this:

.. code:: python

>>> user = UserObject(pk=1, name="Mike", viewers=5)
>>> user.login = 'mike@null.com'
>>> user.login
'mike@null.com'
>>> user.viewers_incr(2)
7
>>> site = SiteObject(pk=1, name="redis.io")
>>> user.site_id = site
>>> user.sites_list.lpush(site, site, site)
3
>>> len(user.sites_list)
3
>>> user.sites_list[2].name
'redis.io'



Install
=======

Python versions 3.3, 3.4, 3.5 are supported.
Redis-py versions >= 2.9.1

.. code:: bash

pip install redis-astra


.. |PyPI Version| image:: https://img.shields.io/pypi/v/redis-astra.png
:target: https://pypi.python.org/pypi/redis-astra
.. |Build Status| image:: https://travis-ci.org/pilat/redis-astra.png
:target: https://travis-ci.org/pilat/redis-astra

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

redis-astra-0.4.5.zip (9.2 kB view details)

Uploaded Source

File details

Details for the file redis-astra-0.4.5.zip.

File metadata

  • Download URL: redis-astra-0.4.5.zip
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for redis-astra-0.4.5.zip
Algorithm Hash digest
SHA256 fff87eadaed994284792207d293b905d7a93a84bb640fd521b03eed9f31d8e77
MD5 fe695d6f212c0ddb2abc4d10c573dd0a
BLAKE2b-256 a9a35b6d1b2ab2e93a852b816a0a770d359c027dc4781834b4a6aee7788b6fd4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page