Skip to main content

DStore MongoDB Storage Layer

Project description

https://img.shields.io/coveralls/MarkLark/dstore-mongo.svg https://img.shields.io/travis/MarkLark/dstore-mongo/master.svg https://img.shields.io/pypi/v/dstore-mongo.svg https://img.shields.io/pypi/pyversions/dstore-mongo.svg

DStore-Mongo is a MongoDB storage layer for DStore. This allows you to use the same Model descriptions to Create, Read, Update and Delete from a Mongo DataBase.

Installing

DStore-Mongo is available from the PyPi repository.

This means that all you have to do to install DStore-Mongo is run the following in a console:

$ pip install dstore-mongo

Minimal Example

from dstore import Model, var, mod
from dstore_mongo import MongoStore

class Car( Model ):
    _namespace = "cars.make"
    _vars = [
        var.RowID,
        var.String( "manufacturer", 32, mods = [ mod.NotNull() ] ),
        var.String( "make", 32, mods = [ mod.NotNull() ] ),
        var.Number( "year", mods = [ mod.NotNull(), mod.Min( 1950 ), mod.Max( 2017 ) ] ),
    ]

# Create the MemoryStore instance, and add Models to it
store = MongoStore( self.models )
store.init_app()
store.set_config({
    "DSTORE_DB_HOST"  : "localhost",
    "DSTORE_DB_USER"  : "username",
    "DSTORE_DB_PASSWD": "password",
    "DSTORE_DB_DB"    : "dstoredb"
})
store.connect()
store.create_all()

# Destroy all instances and shut down the application
store.destroy_all()
store.disconnect()
store.destroy_app()

Documentation: ReadTheDocs

Source Code: GitHub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
DStore_Mongo-0.1.0a1-py2.py3-none-any.whl (5.1 kB) Copy SHA256 hash SHA256 Wheel py2.py3
DStore-Mongo-0.1.0a1.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page