Skip to main content

Object data mapper and advanced query manager for non relational databases.

Project description

Object data mapper and advanced query manager for non relational databases.

The data is owned by different, configurable back-end databases and it is accessed using a light-weight Object Data Mapper (ODM). The ODM presents a method of associating user-defined Python classes with database collections, and instances of those classes with items in their corresponding collections. Collections and items are different for different backend databases but are treated in the same way in the python language domain.

Master CI:


Dev CI:





Mailing List:


server, database, cache, redis, mongo, odm



  • Models with scalar and multi-value fields.

  • Rich query API including unions, intersections, exclusions, ranges and more.

  • Minimal server round-trips via backend scripting (lua for redis).

  • Full text search.

  • Signals handling to allow decoupled applications to get notified on changes.

  • Synchronous and asynchronous database connection.

  • Multi-variate numeric timeseries application.

  • Asynchronous Publish/Subscribe application.

  • 90% Test coverage.

  • Fully documented.


  • Python 2.6, 2.7, 3.2, 3.3 and pypy. Single code-base.

  • redis-py for redis backend.

  • Optional pymongo for the mongo backend.

  • Optional pulsar when using the asynchronous connections or the test suite.

  • You need access to a Redis server version 2.6 or above and/or a Mongo server.


Key-valued pairs databases, also know as key-value stores, have many differences from traditional relational databases, most important being they do not use SQL as their query language, storage does not require a fixed table schemas and usually they do not support complex queries.

Stdnet aims to accommodate a flexible schema and join type operations via a lightweight object data mapper. Importantly, it is designed with large data sets in mind. You pull data you need, nothing more, nothing less. Bandwidth and server round-trips can be reduced to the bare minimum so that your application is fast and memory efficient.


To install, download, uncompress and type:

python install

otherwise use easy_install:

easy_install python-stdnet

or pip:

pip install python-stdnet

Version Check

To know which version you have installed:

>>> import stdnet
>>> stdnet.__version__
>>> stdnet.VERSION
stdnet_version(major=0, minor=8, micro=0, releaselevel='final', serial=1)


Backend data-stores are the backbone of the library. Currently the list is limited to

Object Data Mapper

The stdnet.odm module is the ODM, it maps python objects into database data and vice-versa. It is design to be fast and safe to use:

from stdnet import odm

class Base(odm.StdModel):
    '''An abstract model. This won't have any data in the database.'''
    name = odm.SymbolField(unique = True)
    ccy  = odm.SymbolField()

    def __unicode__(self):

    class Meta:
        abstract = True

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

class Fund(Base):
    description = odm.CharField()

class PositionDescriptor(odm.StdModel):
    dt    = odm.DateField()
    size  = odm.FloatField()
    price = odm.FloatField()
    position = odm.ForeignKey("Position", index=False)

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

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

Register models with backend:

models = orm.Router('redis://localhost?db=1')

And play with the API:

>>> f ="pluto, description="The pluto fund", ccy="EUR")
>>> f
Fund: pluto

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 you can find sources from MSOpenTech.

Requirements for running tests:

  • python-stdnet project directory.

  • pulsar.

To run tests open a shell and launch Redis. On another shell, from within the python-stdnet 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 --server option as follow:

python --server 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 html


  • Redis simply because this library uses its awesome features.

  • SQLAlchemy and Django for ideas and API design.


Development of stdnet happens at Github:

We very much welcome your contribution of course. To do so, simply follow these guidelines:

  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.8.1.tar.gz (178.7 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