1. Introduction To DStore

DStore (DataStore) is a Python Object Relational Mapper (ORM) that allows easy description of data models.

1.1. Installing

1.1.1. From PyPi

DStore is available from the PyPi repository at DStore.

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

$ pip install dstore

1.1.2. From Source

DStore can also be installed from source by downloading from GitHub and running setup.py.

$ wget https://github.com/MarkLark/dstore/archive/master.tar.gz
$ tar xvf master.tar.gz
$ cd dstore-master
$ python setup.py install

1.2. Requirements

DStore does not rely on any other Python Packages.

It has also been thoroughly tested to work on the following Python Versions:

  • 2.7
  • 3.3
  • 3.4
  • 3.5
  • 3.6

1.3. Minimal Example

from dstore import MemoryStore, Model, var, mod

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 = MemoryStore( [ Car ] )
store.init_app()
store.connect()
store.create_all()

# Create a new Car, then retrieve it using filter and all
Car( manufacturer = "Holden", make = "Commodore", year = 2010 ).add()
holdens = Car.filter( manufacturer = "Holden" )
cars = Car.all()

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

1.4. How It Works

DStore works by defining the models that you wish to use. It then provides a layer for storing the model instances.