tool v0.5.0 documentation

SQLObject ORM

«  Document storage   ::   Contents   ::   Storm ORM  »

SQLObject ORM

state:stable
dependencies:SQLObject
feature:orm

Support for SQLObject, a popular Object Relational Manager for providing an object interface to your database, with tables as classes, rows as instances, and columns as attributes.

Configuration

Example configuration (YAML):

tool.ext.sqlobject_orm.SQLObjectExtension:
    uri: "sqlite:/:memory:"

Usage

Example usage:

from sqlobject import *
from tool import app

orm = app.get_feature('orm')

# declare the model
class Person(SQLObject):
    name = StringCol()

# create database
orm.db.createEmptyDatabase()

# create table
Person.createTable()

# create row
Person(name="John")

# fetch row
Person.get(1)

# query
people = Person.select(Person.q.name=='John')

See the SQLObject documentation for details. Just remember that our database connection is available as orm.db where orm is the extension object.

API reference

class tool.ext.sqlobject_orm.SQLObjectExtension(app, conf)

Adds the ORM feature.

Required configuration options:

Parameter:uri – a string describing the connection, as follows: scheme://username:password@hostname:port/database_name (see declaring a connection in SQLObject documentation).
db
The connection instance, as configured here by tool.application.Application.

«  Document storage   ::   Contents   ::   Storm ORM  »