futurice/django-saber

Name: django-saber

Owner: Futurice

Description: null

Created: 2015-10-09 11:54:05.0

Updated: 2017-06-07 07:45:18.0

Pushed: 2016-06-16 07:36:58.0

Homepage: null

Size: 19

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

django-saber

Saber provides a drop-in replacement for the Django ORM for dealing with a defined database set. All Model attributes, methods and relations will work seamlessly – faster.

Why

This library helped reduce the generation of an expensive report from 200 seconds to 1 second, by changing a prefetched queryset with an in-memory data representation.

Usage

Your Django project should separate concerns; that is, separate Models (fields) and Controllers (logic). This allows Saber to use the same logic.

s ThinController(object):
 name_rhymes_with_orange(self): pass

s Thin(ThinController, models.Model):
e = models.CharField(max_length=255)

To mimic Models, provide the module that has the model Controllers. By default, memory.initialize() will load the full database into memory.

ry = Memory(controllers=['test_project.controllers'])
ry.initialize()
base = Traverse(memory.data)
base.thin.all() 
base.thin[0].name
base.thin[0].name_rhymes_with_orange()
License

BSD-3 see LICENSE


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.