Quickstart

Minimal application

A minimal Broadway-SQLAlchemy application looks something like this:

import broadway

factory = broadway.factory()

factory.add_extension('broadway_sqlalchemy')

app = factory(__name__)

from broadway_sqlalchemy import extension as db

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __init__(self, username, email):
        self.username = username
        self.email = email

    def __repr__(self):
        return '<User %r>' % self.username

Save this as app.py, and run the the server using the flask command line.

$ export SQLALCHEMY_DATABASE_URI=sqlite:////tmp/test.db
$ export FLASK_APP=app.py
$ flask run
* Serving Flask app "app"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Broadway will use the extension to load and configure Flask-SQLAlchemy. An instance will be available as broadway_sqlalchemy.extension.