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

Overview

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: master-build coverage
Dev CI: dev-build coverage-dev
Documentation: http://pythonhosted.org/python-stdnet/
Dowloads: http://pypi.python.org/pypi/python-stdnet/
Source: https://github.com/lsbardel/python-stdnet
Platforms: Linux, OS X, Windows. Python 2.6, 2.7, 3.2, 3.3, pypy
Mailing List: https://groups.google.com/group/python-stdnet
Keywords: server, database, redis, odm

Contents

Features

  • 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.

Requirements

  • Python 2.6, 2.7, 3.2, 3.3 and pypy. Single code-base.
  • redis-py for redis backend.
  • Optional pulsar when using the asynchronous connections or the test suite.
  • You need access to a Redis server version 2.6 or above.

Philosophy

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.

Installing

To install, download, uncompress and type:

python setup.py 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__
'0.8.0'
>>> stdnet.VERSION
stdnet_version(major=0, minor=8, micro=0, releaselevel='final', serial=1)

Backends

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):
        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: 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:

python runtests.py

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 runtests.py --server redis://myserver.com:6450?db=12&password=bla

For more information type:

python runtests.py -h

Kudos

  • Redis simply because this library uses its awesome features.
  • SQLAlchemy and Django for ideas and API design.

Contributing

Development of stdnet happens at Github: http://github.com/lsbardel/python-stdnet

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 https://github.com/lsbardel/python-stdnet/issues with a link to your patch

License

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

Owner
Luca Sbardella
quantitative wizard at @quantmind
Luca Sbardella
适用于HoshinoBot下的雀魂插件。可进行近期对局查询、查询个人数据等功能,更多功能正在扩展

Majsoul_bot This is a Majsoul plugin for HoshinoBot 这是一个HoshinoBot的雀魂相关插件 本项目目前正在扩展,后续会扩展更多功能,敬请期待 前言 项目地址:https://github.com/DaiShengSheng/Majsoul_bo

黛笙笙 33 Dec 14, 2022
Amazon SageMaker Delta Sharing Examples

This repository contains examples and related resources showing you how to preprocess, train, and serve your models using Amazon SageMaker with data fetched from Delta Lake.

Eitan Sela 5 May 02, 2022
A web application (with multiple API project options) that uses MariaDB HTAP!

Bookings Bookings is a web application that, backed by the power of the MariaDB Connectors and the MariaDB X4 Platform, unleashes the power of smart t

MariaDB Corporation 4 Dec 28, 2022
Gobigger Explore For Python

Gobigger-Explore 🔮 GoBigger Challenge 2021 Baseline en/中文 🤖 Introduction This is the baseline of GoBigger Multi-Agent Decision Intelligence Challeng

OpenDILab 145 Dec 22, 2022
A program that analyzes data from inertia measurement units installeed in aircraft and generates g-exceedance curves

A program that analyzes data from inertia measurement units installeed in aircraft and generates g-exceedance curves

Pooya 1 Nov 23, 2021
This wishes a mentioned users on their birthdays

BirthdayWisher Requirements: "mysqlserver", "email id and password", "Mysqlconnector" In-Built Modules: "smtplib", "datetime","imghdr" In Mysql: A tab

vellalaharshith 1 Sep 13, 2022
dotfiles - Cristian Valero Abundio

In this repository you can find various configurations to configure your Linux operating system, preferably ArchLinux and its derivatives.

Cristian Valero Abundio 1 Jan 09, 2022
Find your desired product in Digikala using this app.

Digikala Search Find your desired product in Digikala using this app. با این برنامه محصول مورد نظر خود را در دیجیکالا پیدا کنید. About me Full name: M

Matin Ardestani 17 Sep 15, 2022
Create VSCode Extensions with python

About Create vscode extensions with python. Installation Stable version: pip install vscode-ext Why use this? Why should you use this for building VSc

Swas.py 134 Jan 07, 2023
Small exercises to get you used to reading and writing Python code!

Pythonlings Welcome to Pythonlings, an automated Python tutorial program (inspired by Rustlings and Haskellings). WIP This program is still working in

鹤翔万里 5 Sep 23, 2022
This code extracts line width of phonons from specular energy density (SED) calculated with LAMMPS.

This code extracts line width of phonons from specular energy density (SED) calculated with LAMMPS.

Masato Ohnishi 3 Jun 15, 2022
Get a list of all offline/online members in a discord server

Discord server insights Get a list of all offline/online members in a discord server. Uses Selenium to crawl invite links. Config Download Chrome driv

Prakhar Gurunani 3 Oct 21, 2022
Open Source Repository for CFD Solvers

Background and Validation This wiki is built in Notion. Here are all the tips you need to contribute. General Background Flow over a cylinder The proj

1 Dec 30, 2021
Prophet is a tool to discover resources detailed for cloud migration, cloud backup and disaster recovery

Prophet is a tool to discover resources detailed for cloud migration, cloud backup and disaster recovery

22 May 31, 2022
Experimental proxy for dumping the unencrypted packet data from Brawl Stars (WIP)

Brawl Stars Proxy Experimental proxy for version 39.99 of Brawl Stars. It allows you to capture the packets being sent between the Brawl Stars client

4 Oct 29, 2021
A simple desktop application to scan and export Genshin Impact Artifacts.

「天目」 -- Amenoma 简体中文 | English 「天目流的诀窍就是滴水穿石的耐心和全力以赴的意志」 扫描背包中的圣遗物,并导出至 json 格式。之后可导入圣遗物分析工具( 莫娜占卜铺 、 MingyuLab 、 Genshin Optimizer 进行计算与规划等。 已支持 原神2.

夏至 475 Dec 30, 2022
My solutions for the 2021's Advent of Code

Advent of Code 2021 My solutions for Advent of Code 2021. This year I am practicing Python 🐍 and also trying to develop my own language, Chocolate 🍫

Jakob Erzar 2 Dec 15, 2021
Canim1 - Simple python tool to search for packages without m1 wheels in poetry lockfiles

canim1 Usage Clone the repo. Run poetry install. Then you can use the tool: ❯ po

Korijn van Golen 1 Jan 25, 2022
A tool that bootstraps your dotfiles ⚡️

Dotbot Dotbot makes installing your dotfiles as easy as git clone $url && cd dotfiles && ./install, even on a freshly installed system! Rationale Gett

Anish Athalye 5.9k Jan 07, 2023
Port of the OpenCascade library to JavaScript / WebAssembly using Emscripten

OpenCascade.js A port of the OpenCascade CAD library to JavaScript and WebAssembly via Emscripten. Explore the docs » Examples · Issues · Discuss Proj

Sebastian Alff 347 Jan 08, 2023