Package: python-stdnet
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 databasecollections,
and instances of those classes withitemsin 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:Documentation:http://pythonhosted.org/python-stdnet/Dowloads:http://pypi.python.org/pypi/python-stdnet/Source:https://github.com/lsbardel/python-stdnetMailing List:https://groups.google.com/group/python-stdnetKeywords:server, database, cache, redis, mongo, odmContentsFeaturesRequirementsPhilosophyInstallingVersion CheckBackendsObject Data MapperRunning TestsKudosContributingLicenseFeaturesModels 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.RequirementsPython 2.6, 2.7, 3.2, 3.3 andpypy. Single code-base.redis-pyfor redis backend.Optionalpymongofor the mongo backend.Optionalpulsarwhen using the asynchronous connections or the test suite.You need access to aRedisserver version 2.6 or above and/or aMongoserver.PhilosophyKey-valued pairs databases, also know as key-value stores, have many differences
from traditional relational databases,
most important being they do not useSQLas 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.InstallingTo install, download, uncompress and type:python setup.py installotherwise useeasy_install:easy_install python-stdnetorpip:pip install python-stdnetVersion CheckTo know which version you have installed:>>> import stdnet
>>> stdnet.__version__
'0.8.0'
>>> stdnet.VERSION
stdnet_version(major=0, minor=8, micro=0, releaselevel='final', serial=1)BackendsBackend data-stores are the backbone of the library.
Currently the list is limited toRedis2.6 or above.Mongodb(alpha).Object Data MapperThestdnet.odmmodule 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):
        return self.name

    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.fund,self.instrument,self.dt)Register models with backend:models = orm.Router('redis://localhost?db=1')
models.register(Instrument)
models.register(Fund)
models.register(PositionDescriptor,'redis://localhost?db=2')
models.register(Position,'redis://localhost?db=2')And play with the API:>>> f = models.fund.new(name="pluto, description="The pluto fund", ccy="EUR")
>>> f
Fund: plutoRunning TestsAt the moment, only redis back-end is available and therefore to run tests you
need to installRedis. If you are using linux, it can be achieved simply
by downloading, uncompressing and runningmake, if you are using
windows you can find sources fromMSOpenTech.Requirements for running tests:python-stdnetproject directory.pulsar.To run tests open a shell and launch Redis. On another shell,
from within thepython-stdnetpackage directory, type:python runtests.pyTests are run against a local redis server on port6379and database 7 by default.
To change the server and database where to run tests pass the--serveroption as follow:python runtests.py --server redis://myserver.com:6450?db=12&password=blaFor more information type:python runtests.py -hTo access coverage of tests you need to install thecoveragepackage and run the tests using:coverage run runtests.pyand to check out the coverage report:coverage htmlKudosRedissimply because this library uses its awesome features.SQLAlchemyandDjangofor ideas and API design.ContributingDevelopment of stdnet happens at Github:http://github.com/lsbardel/python-stdnetWe very much welcome your contribution of course. To do so, simply follow these guidelines:Fork python-stdnet on githubCreate a topic branchgit checkout-bmy_branchPush to your branchgit push origin my_branchCreate an issue athttps://github.com/lsbardel/python-stdnet/issueswith a link to your patchLicenseThis software is licensed under the NewBSDLicense. See the LICENSE
file in the top distribution directory for the full license text.