minimodels

A backend-independent database abstraction tool.


Keywords
model, backend, abstraction
License
BSD-3-Clause
Install
pip install minimodels==0.1.0

Documentation

minimodels

This library aims to provide a generic abstraction over various data storage backends. It provides a simple, declarative API for data structures, which can then be mapped to custom backends.

Note

This is only a draft documentation, no actual code yet!

Example

class User(minimodels.Model):
    first_name = minimodels.fields.CharField()
    last_name = minimodels.fields.CharField()

>>> user = User(first_name="John", last_name="Lennon")
>>> user.serialize('json')
'{"first_name": "John", "last_name": "Lennon"}'

Backends

A specific backend may be provided for each model, in its Meta class:

class User(minimodels.Model):
    # Field definitions

    class Meta:
        backend = minimodels.backends.Redis(settings.REDIS_URL, prefix='user')

>>> user = User(username='john', first_name="John", last_name="Lennon")
>>> user.save()

>>> user = User.objects.get(username='john')
<User: John Lennon>