{ "info": { "author": "Vitaliy Khamin", "author_email": "vitaliykhamin@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Master branch: |Build Status|\n\n.. |Build Status| image:: https://travis-ci.org/khamin/redisca.png?branch=master\n :target: https://travis-ci.org/khamin/redisca\n\nInstallation\n============\n\nUsing PyPi (recommended):\n\n::\n\n\tsudo pip install redisca\n\nor\n\n::\n\n\twget https://pypi.python.org/packages/source/r/redisca/redisca-X.tar.gz\n\ttar xvf redisca-X.tar.gz\n\tsudo python redisca-X/setup.py install\n\nModel\n=====\n\n.. code:: python\n\n from redisca import Model\n from redisca import Email\n from redisca import DateTime\n\n class User (Model):\n\t email = Email(\n\t\t field='eml', # Define link with 'eml' hash key.\n\t\t index=True, # Index support.\n\t\t unique=True, # Makes sure that field is unique across db.\n\t )\n\n\t created = DateTime(\n\t\t field='created',\t # Define link with 'created' hash key.\n\t\t new=datetime.utcnow, # Value which is used as default in User.new()\n\t )\n\n\t age = Integer(\n\t\t field='age', # Define link with 'age' hash key.\n\t\t index=True, # Enable index.\n\t )\n\n user = User.new() # Create model with random id and \"new\" fields values.\n user = User.new(model_id='your_id') # Or use custom id if needed.\n\n user.getid() # user id\n user.email = 'foo@bar.com'\n\n user.save() # Saving routines\n user.exists() # True\n\n user.delete() # Deletion routines\n user.exists() # False\n\nFields\n------\n\nField is the way how you should control data in your models. Just define class variables with field-specific options and take classic ORM's advantages:\n\n- data validation;\n- native python data types support;\n- transparent relations between models;\n- indexes support (incl. unique indexes).\n\nAvailable parameters:\n\n- **field** - redis hash field name to store value in.\n- **index** - makes field searchable.\n- **unique** - tells that value should be unique across database. Model.save() will raise an Exception if model of same class already exists with given value.\n- **new** - field value which is used as default in Model.new(). Functions, methods and built-in's are acceptable as callback values.\n\nBuilt-in fields:\n\n- **String** - extends *IndexField* with additional parameters *minlen* and *maxlen*.\n- **Email** - extends *IndexField* field with email validation support.\n- **Integer** - extends *RangeIndexField* with parameters *minval* and *maxval*. Accepts int and numeric strings. Returns int.\n- **Reference** - extends *IndexField* with *cls* (reference class) parameter. Accepts and returns instance of *cls*.\n- **MD5Pass** - extends *String* field. Acts like string but converts given string to md5 sum.\n- **DateTime** - extends *RangeIndexField* without additional parameters. Accepts datetime and int(timestamp) values. Returns datetime.\n\nGetting Data\n------------\n\nUsing id\n~~~~~~~~\n\nHere is an example how to get model instance using id *(empty model returned if it not exists yet)*:\n\n.. code:: python\n\n\tuser = User('user id')\n\tprint(user.email) # 'foo@bar.com'\n\nEach initialized model is saved in registry and returned on each attempt of re-init:\n\n.. code:: python\n\n\tuser1 = User('user_id')\n\tuser2 = User('user_id')\n\tuser1 is user2 # Always is True\n\n\tuser.free() # Unregister model instance.\n\tUser.free_all() # Cleanup User's registry.\n\tModel.free_all() # Unregister all known models.\n\nFind by Index\n~~~~~~~~~~~~~\n\n.. code:: python\n\n\tusers = User.email == 'foo@bar.com' # or User.email.find('foo@bar.com')\n\nSubclasses of *RangeIndexField* has a limited support for ranged queries:\n\n.. code:: python\n\n\tusers = User.age >= 10 # User.age.range(minval=10)\n\nMore complex queries are also possible:\n\n.. code:: python\n\n\t# SELECT * FROM `users` where `age` BETWEEN 0 AND 100 LIMIT 10 OFFSET 50;\n\tusers = User.age.range(minval=0, maxval=100, start=50, num=10)\n\nDict API\n~~~~~~~~\n\nAll fields are linked to model dict keys. Use can use model dict API to read and write *redis hash* data AS IS:\n\n.. code:: python\n\n\tuser = User('id')\n\tuser['eml'] = 'foo@bar.com'\n\tuser['age'] = 10\n\nConnecting to Redis\n-------------------\n\nGlobal database connection setup looks like this:\n\n.. code:: python\n\n\tfrom redisca import conf\n\tfrom redis import Redis\n\n\tconf.db = Redis()\n\n**Note:** *redisca* uses localhost:6379(0) as default database. You can setup **inheritable** per-model database connection using *conf* class decorator:\n\n.. code:: python\n\n\tfrom redisca import Model\n\tfrom redisca import conf\n\n\tfrom redis import Redis\n\n\t@conf(db=Redis())\n\tclass User (Model):\n\t\tpass\n\nKey Format\n----------\n\nModel key format is:\n\n::\n\n\tmodel_key_prefix:model_id\n\nDefault model\\_key\\_prefix is *lowercased class name*. Use *conf* class decorator to override it like this:\n\n.. code:: python\n\n\tfrom redisca import Model\n\tfrom redisca import conf\n\n\t@conf(prefix='usr')\n\tclass User (Model):\n\t\tpass\n\n\tprint(User.getprefix()) # 'usr'\n\tprint(user.getkey()) # 'usr:1'\n\nTools\n=====\n\nID Generator\n------------\n\n.. code:: python\n\n\tfrom redisca import hexid\n\tfrom redisca import intid\n\n\tprint(hexid()) # 59d369790\n\tprint(hexid()) # 59d3697bc\n\n\tprint(intid()) # 24116751882\n\tprint(intid()) # 24116788848\n\nFlask Support\n-------------\n\n.. code:: python\n\n\tfrom redisca import FlaskRedisca\n\n\tapp = Flask()\n\n\tapp.config['REDISCA'] = {\n\t\t# redis.StrictRedis constructor kwargs dict.\n\t}\n\n\tFlaskRedisca(app)\n\nOptional *autosave* constructor parameter tells *redisca* that all known models should be saved at the end of request (if no exception raised). Unchanged and deleted instances are ignored. If you want to skip locally changed instances use free() method during request life.\n\nRequirements\n============\n\n- redis-py 2.7+\n- python 2.7/3.2+ or pypy 2.1+\n\nPython 3.x support\n------------------\n\nPy3k support is still a sort of experiment but I'm looking carefuly into full compability with cutting-edge builds of CPython. There are no known issues with it actually.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/khamin/redisca", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "redisca", "package_url": "https://pypi.org/project/redisca/", "platform": "any", "project_url": "https://pypi.org/project/redisca/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/khamin/redisca" }, "release_url": "https://pypi.org/project/redisca/1.3/", "requires_dist": null, "requires_python": null, "summary": "Lightweight ORM for Redis", "version": "1.3" }, "last_serial": 1036038, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "e0a5deb995a17a4a825444575b89738e", "sha256": "35b9a3f1ecd86df3e07b44c58cf9d78cdf63c796554288e1719f196aedc7eca9" }, "downloads": -1, "filename": "redisca-1.0.tar.gz", "has_sig": false, "md5_digest": "e0a5deb995a17a4a825444575b89738e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10106, "upload_time": "2013-11-06T17:08:32", "url": "https://files.pythonhosted.org/packages/ed/c5/be46cc2eb0c334669191e63a91fd324e8545a1340651fe523707a5deaa58/redisca-1.0.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "e7a1ed63a9f293dba57b2e0355a7c7f6", "sha256": "7941bab76003d11d9a99b32b7cb286d10e10ac9fdf365334bc7ebb11584c29ca" }, "downloads": -1, "filename": "redisca-1.0b2.tar.gz", "has_sig": false, "md5_digest": "e7a1ed63a9f293dba57b2e0355a7c7f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5491, "upload_time": "2013-08-13T05:11:00", "url": "https://files.pythonhosted.org/packages/44/40/8615e8b058d865849d051d4b8d537417acd2119d11380f3c1a34ab8ec123/redisca-1.0b2.tar.gz" } ], "1.0b3": [ { "comment_text": "", "digests": { "md5": "64fe47fb93edb7f3503ed1505c35dbe0", "sha256": "68aab96f6eb9f431a13d8ecbdd1b9409dcc1d1de02c4b1c26da73987d530ef4d" }, "downloads": -1, "filename": "redisca-1.0b3.tar.gz", "has_sig": false, "md5_digest": "64fe47fb93edb7f3503ed1505c35dbe0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5773, "upload_time": "2013-08-14T07:19:29", "url": "https://files.pythonhosted.org/packages/a3/2c/650e7f0a59aa1a811046aae95a037bf75e9d67861985f16ce84a9a81153b/redisca-1.0b3.tar.gz" } ], "1.0b4": [ { "comment_text": "", "digests": { "md5": "22f8d8b51ff4c954d54b933232996b74", "sha256": "769c63798df8fd22d1bef6c2e2d75ce305a3285e68bb263ee2542ff9e916caad" }, "downloads": -1, "filename": "redisca-1.0b4.tar.gz", "has_sig": false, "md5_digest": "22f8d8b51ff4c954d54b933232996b74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6461, "upload_time": "2013-08-17T05:00:09", "url": "https://files.pythonhosted.org/packages/28/17/9850cd5d237d298a43cf9079106432ff633bf0805bf13492c838cb15c35f/redisca-1.0b4.tar.gz" } ], "1.0b5": [ { "comment_text": "", "digests": { "md5": "e7a27a8275bb88759bea178a6df11ba2", "sha256": "241ea6d588e3112d3d5bd92cf488368eb3f1629c5839c0d7c9648d543baa35a3" }, "downloads": -1, "filename": "redisca-1.0b5.tar.gz", "has_sig": false, "md5_digest": "e7a27a8275bb88759bea178a6df11ba2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9088, "upload_time": "2013-08-21T15:46:11", "url": "https://files.pythonhosted.org/packages/8f/ec/4c9aa90d22d516106701e2687fd3cdbfaf85b8f182a9bb7078e349b0ef07/redisca-1.0b5.tar.gz" } ], "1.0b6": [ { "comment_text": "", "digests": { "md5": "6f54cfbe6eacad02331a79c45059e19e", "sha256": "50e627d375f1a65b0a2db163407816ce8f64acadea2d0ecc77c496c7fa4c9345" }, "downloads": -1, "filename": "redisca-1.0b6.tar.gz", "has_sig": false, "md5_digest": "6f54cfbe6eacad02331a79c45059e19e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9900, "upload_time": "2013-10-31T09:54:38", "url": "https://files.pythonhosted.org/packages/11/c0/ddd720269f267e4d22015ce73743248bef9e4ca79a4e2b4009004815e131/redisca-1.0b6.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "b3316b7329eb3fc5f721df425161d094", "sha256": "c5a03c262a6c0ade2b55f1cc80d208793e89fc04fa2325184663e82c25fb5bef" }, "downloads": -1, "filename": "redisca-1.1.tar.gz", "has_sig": false, "md5_digest": "b3316b7329eb3fc5f721df425161d094", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10109, "upload_time": "2013-12-13T15:42:17", "url": "https://files.pythonhosted.org/packages/76/d6/438dc4426795ffa626794d5db9c4cbf6a43697e0649fb46a3443e2391748/redisca-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "9dba3bfa90ec1cc35a972514900bf2f1", "sha256": "92981eabf52c758a75fa46ae7a1d6b0912a75f7825266e9c2351864e270467de" }, "downloads": -1, "filename": "redisca-1.2.tar.gz", "has_sig": false, "md5_digest": "9dba3bfa90ec1cc35a972514900bf2f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10723, "upload_time": "2014-02-07T12:09:01", "url": "https://files.pythonhosted.org/packages/69/8d/8996c4ed8540e746891163b68302082d68f70ec1444ba1b9e7deea39fee6/redisca-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "0874540a0021ad0ede5e3afb63c0704b", "sha256": "ed34d642a70707aa96a52fbfe150eb9aef544b4ddcd78c9113ff92059513691d" }, "downloads": -1, "filename": "redisca-1.3.tar.gz", "has_sig": false, "md5_digest": "0874540a0021ad0ede5e3afb63c0704b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10783, "upload_time": "2014-03-20T11:27:29", "url": "https://files.pythonhosted.org/packages/e9/7d/cd18f893770d80a52d1b59abe035b56a657e5521c7ffae4aeab50a75ffb9/redisca-1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0874540a0021ad0ede5e3afb63c0704b", "sha256": "ed34d642a70707aa96a52fbfe150eb9aef544b4ddcd78c9113ff92059513691d" }, "downloads": -1, "filename": "redisca-1.3.tar.gz", "has_sig": false, "md5_digest": "0874540a0021ad0ede5e3afb63c0704b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10783, "upload_time": "2014-03-20T11:27:29", "url": "https://files.pythonhosted.org/packages/e9/7d/cd18f893770d80a52d1b59abe035b56a657e5521c7ffae4aeab50a75ffb9/redisca-1.3.tar.gz" } ] }