Skip to main content

An object relational mapper library for Redis remote data structures.

Project description

A Python 3 compatible object relational mapper for Redis remote data structures.

The data is owned by different, configurable back-end databases and it is accessed using a light-weight Object Relational Mapper (ORM) inspired by Django and SQLAlchemy. The source code and documentation are hosted at github while Downloads are available via PyPi.





Mailing List:


server, database, cache, redis, orm


  • You need access to a Redis server.

  • Python 2.6 or above, including Python 3 series.


To install, download, uncompress and type:

python install

otherwise use easy_install:

easy_install python-stdnet

or pip:

pip install python-stdnet


StdNet uses Sphinx for its documentation, and the latest is available at GitHub:

Version Check

To know which version you have installed:

>>> import stdnet
>>> stdnet.__version__

Running Tests

At the moment, only redis back-end is available and therefore to run tests you need to install Redis. If you are using linux, it can be achieved simply by downloading, uncompressing and running make, if you are using windows and want to save yourself a headache you can download precompiled binaries at servicestack.

If you are running python 2.6, 3 and 3.1 you need to install the argparse package, which is a standard in python 2.7 and python >= 3.2. Once done that, open a shell and launch Redis. On another shell, from the package directory, type:


Tests are run against a local redis server on port 6379 and database 7 by default. To change the server and database where to run tests pass the -s option as follow:

python -s redis://

For more information type:

python -h

To access coverage of tests you need to install the coverage package and run the tests using:

coverage run

and to check out the coverage report:

coverage report -m


Backend data-stores provide the backbone of the library, while the Object Relational Mapper the syntactic sugar. Currently the list of back-ends is limited to

  • Redis.

  • Local memory (planned). For testing purposes.

Only Redis is operational.

Object Relational Mapper

The module stdnet.orm is the ORM, it maps python object into database data. It is design to be fast and safe to use:

from stdnet import orm

class Base(orm.StdModel):
    '''An abstract model. This won't have any data in the database.'''
    # A unique symbol field, a symbol is an immutable string
    name = orm.SymbolField(unique = True)
    # Another symbol, symbol fields are by default indexes
    ccy  = orm.SymbolField()

    def __str__(self):
        return str(

    class Meta:
        abstract = True

class Instrument(Base):
    itype = orm.SymbolField()

class Fund(Base):
        # A char field is a string and it is never an index
    description = orm.CharField()

class PositionDescriptor(orm.StdModel):
    dt    = orm.DateField()
    # A float field is not an index by default
    size  = orm.FloatField()
    price = orm.FloatField()
    # A FK field which we explicitly set as non-index
    position = orm.ForeignKey("Position", index = False)

class Position(orm.StdModel):
    instrument = orm.ForeignKey(Instrument, related_name = 'positions')
    fund       = orm.ForeignKey(Fund)
    history    = orm.ListField(model = PositionDescriptor)

    def __str__(self):
        return '%s: %s @ %s' % (,self.instrument,self.dt)

Register models with backend:


And play with the API:

>>> f = Fund(name="pluto,description="The super pluto fund",ccy="EUR").save()
Fund: pluto


  • Redis simply because this library uses its awesome features.

  • redis-py for the Redis Python client initial implementation which has been subsequently modified.

  • Django for some ideas and the dispatch module.

  • Armin Ronacher and Ask Solem for the celery sphinx theme used for the documentation.


Development of StdNet happens at Github:

You are highly encouraged to participate in the development. Here how to do it:

  1. Fork python-stdnet on github

  2. Create a topic branch (git checkout -b my_branch)

  3. Push to your branch (git push origin my_branch)

  4. Create an issue at with a link to your patch


This software is licensed under the New BSD License. See the LICENSE file in the top distribution directory for the full license text.

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

python-stdnet-0.6.2.tar.gz (140.2 kB view hashes)

Uploaded Source

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