Skip to main content

A simple redis ORM

Project description

RedORM

A simple Redis ORM that only a madman would use in production.
The red in RedORM both means Redis as well as the color red, as red is the fastest colour!

Quick Start

To install pip install redorm

from dataclasses import dataclass
from redorm import RedisBase, one_to_one, one_to_many, many_to_one, many_to_many


@dataclass
class Person(RedisBase):
    name: str
    age: int
    siblings = many_to_many(foreign_type="Person", backref="siblings")
    dad = many_to_one(foreign_type="Person", backref="children")
    children = one_to_many(foreign_type="Person", backref="dad")
    favourite_color = one_to_one("Color", backref="liker")


@dataclass
class Color(RedisBase):
    name: str
    liker = one_to_one(Person, backref="favourite_color")
>>> red = Color.create(name="Red")
>>> homer = Person.create(name="Homer", age=50, favourite_color=red)
>>> print(repr(homer.favourite_color))
Color(id='dcb9aa50-554a-40a5-9acf-7d86c982e5ee', name='Red')
>>> print(repr(homer.children))
[]
>>> bart = Person.create(name="Bart", age=11, dad=homer)
>>> print(repr(homer.children))
[Person(id='424cd574-5382-4d34-89da-7233b3928405', name='Bart', age=11)]
>>> print(repr(bart.favourite_color))
None
>>> blue = Color.create(name="Blue", liker=bart)
>>> print(repr(bart.favourite_color))
Color(id='dc9df3c2-c592-4d87-a45e-f88a346342b4', name='Blue')
>>> print(repr(blue.liker))
Person(id='424cd574-5382-4d34-89da-7233b3928405', name='Bart', age=11)
>>> lisa = Person.create(name="Lisa", age=9, dad=homer.id, siblings=[bart])
>>> print(repr(homer.children))
[Person(id='205a459a-572c-41af-bae3-e6e730aada97', name='Lisa', age=9), Person(id='424cd574-5382-4d34-89da-7233b3928405', name='Bart', age=11)]
>>> bart.dad = None
>>> print(repr(homer.children))
[Person(id='205a459a-572c-41af-bae3-e6e730aada97', name='Lisa', age=9)]

Why Redorm?

  • Thread Safe
  • Very fast
  • Super simple to use
  • Very little boilerplate

Why not Redorm?

  • Made in an afternoon
  • Unlikely to be maintained
  • Not thoroughly tested
  • NOT THOROUGHLY TESTED
  • Writing your own ORM is fantastic for learning, but you should not use it in prod

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

redorm-0.3.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

redorm-0.3.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file redorm-0.3.0.tar.gz.

File metadata

  • Download URL: redorm-0.3.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for redorm-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f58b1dfe6e974706b086b35676abee141f26567c688f3feea035b2464934ca6b
MD5 8deb96ab91de8a6f8445eb1c4cffaeaa
BLAKE2b-256 1020db7586344ff2164e504197edfe31e7bd752778659a4fbef727ff326cf4d0

See more details on using hashes here.

File details

Details for the file redorm-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: redorm-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for redorm-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86e42149f3453e74ea8e940abafe3dd1391e753f0d6e8515495513690d78b6df
MD5 dc962d783af25e1e9ec9849daf993348
BLAKE2b-256 be4e8e2db560dc52199b3a7c3131967d00b8e2e2cf8c21a6fbe4157a158df5dd

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