Using SQLAlchemy models in and out of Flask : <p>I'm trying to build SQLAlchemy models that can be used in Flask and in other non-Flask services. I know that in order to use these objects in Flask I can use the Flask-SQLAlchemy module and build the models like this:</p>

<p>app_builder.py</p>

<pre><code>def create_app(config):

    # Create a Flask app from the passed in settings
    app = Flask('web_service')
    app.config.from_object(config)

    # Attach SQLAlchemy to the application
    from database import db

    db.init_app(app)
</code></pre>

<p>database.py</p>

<pre><code>from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

class Job(db.Model):
    __tablename__ = 'job'

    job_id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(256))

    def __init__(self, description):
        self.description = description
</code></pre>

<p>However it looks like doing this ties the models to using flask_sqlalchemy. I have another service that I would like to use these models in that don't use flask. Is there a way I can reuse these class definitions (maybe by changing db.Model) within a non-Flask specific context?</p>
