Example #1
0
def create_app(root: str, config: str) -> Flask:
    """Create a new Flask application with the provided configuration.

    :param root: The application root module name.
    :param config: The application configuration mode.
    """
    app = Flask(__name__)
    app.config.from_object(CONFIG_PATH_FORMAT % (root, config))

    if app.config["INIT"]["debug"]:
        print(LOG_MODE_DEBUG)
    else:
        print(LOG_MODE_PRODUCTION)

    if app.config["GOOGLECLIENTID"]:
        print(LOG_ID_FORMAT % app.config["GOOGLECLIENTID"])
    else:
        print(LOG_ID_NOT_FOUND)

    # Async socket initialization
    eventlet.monkey_patch()
    socketio.init_app(app)

    # Configuration for mySQL database
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.config["SQLALCHEMY_DATABASE_URI"] = app.config["DATABASE_URL"].replace("mysql", "mysql+pymysql", 1)
    db.init_app(app)

    # Configuration for login sessions
    app.secret_key = app.config["SECRET_KEY"]
    login_manager.init_app(app)

    # Flask Debug Toolbar
    toolbar.init_app(app)

    # Database migration management
    migrate.init_app(app, db)
    migration_manager(app)

    from .public.views import public
    from .queue.views import queue
    from .admin.views import admin
    from .dashboard.views import dashboard

    BLUEPRINTS = [public, queue, admin, dashboard]

    for blueprint in BLUEPRINTS:
        print(' * Registering blueprint "%s"' % blueprint.name)
        app.register_blueprint(blueprint)

    # subdomain routes with special urls
    app.register_blueprint(admin, url_prefix="/subdomain/<string:queue_url>/admin")
    app.register_blueprint(queue, url_prefix="/subdomain/<string:queue_url>")

    # register error handlers
    app.register_error_handler(401, standard_error)
    app.register_error_handler(404, error_not_found)
    app.register_error_handler(500, error_server)

    return app
Example #2
0
 def create_app(self):
     app = Flask(__name__)
     app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
     app.config["TESTING"] = True
     # app.config['SQLALCHEMY_ECHO'] = True
     app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
     db.init_app(app)
     return app
Example #3
0
 def setUp(self):
     app = Flask("tests", static_url_path="/static")
     app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
     app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/test_idb.db"
     db.init_app(app)
     db.app = app
     db.configure_mappers()
     db.create_all()
Example #4
0
def create_app(db_uri="postgresql://@/updatechecker"):
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = db_uri
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.debug = getenv("DEBUG")
    app.register_blueprint(blueprint)
    db.init_app(app)
    return app
Example #5
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///stress.db"
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    db.init_app(app)
    with app.app_context():
        db.create_all()
    return app
Example #6
0
def create_test_app(db_file):
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + db_file
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

    trips_models.db.init_app(app)
    app.app_context().push()

    return app
Example #7
0
def create_flask_app():
    """Creates a configured flask app."""
    app = Flask(__name__, template_folder="templates")
    app.debug = True
    app.secret_key = "secret"
    app.config["DEBUG"] = True
    app.config["SQLALCHEMY_DATABASE_URI"] = _get_db_url()
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    trips_models.db.init_app(app)

    return app
Example #8
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///../sqlite3.db"
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    db.init_app(app)

    app.register_blueprint(page_bp)

    app.register_blueprint(api_v1_bp, url_prefix="/{prefix}/{version}".format(prefix="api", version=API_VERSION_V1))
    app.register_blueprint(api_v2_bp, url_prefix="/{prefix}/{version}".format(prefix="api", version=API_VERSION_V2))

    return app
Example #9
0
def create_app(config_path):
    app = Flask(__name__)
    config = Config(config_path)
    app.config["SQLALCHEMY_DATABASE_URI"] = config.db_path
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.config["APP_LOGFILE"] = config.log_path
    db.init_app(app)

    initialize_logger(app)

    app.errorhandler(404)(error_handlers.page_not_found)
    return app
def create_app():
    """Config for the app"""
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://docker:{}@{}:{}/{}".format(
        os.environ["DATABASE_PASSWORD"],
        os.environ["DATABASE_PORT_5432_TCP_ADDR"],
        os.environ["DATABASE_PORT_5432_TCP_PORT"],
        os.environ["POSTGRES_DB"],
    )
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

    db.init_app(app)

    app.register_blueprint(APP)
    app.register_blueprint(FEEDBACK, url_prefix="/feedback")
    app.register_blueprint(TOURNAMENT, url_prefix="/tournament")
    app.register_blueprint(TOURNAMENT_ROUND, url_prefix="/tournament/<tournament_id>/rounds")
    app.register_blueprint(ENTRY, url_prefix="/tournament/<tournament_id>/entry")
    app.register_blueprint(USER, url_prefix="/user/<username>")

    @app.errorhandler(PermissionDeniedException)
    # pylint: disable=unused-variable
    def permission_denied(err):
        """Permission denied (as opposed to auth failed)"""
        print "{}: {}".format(type(err).__name__, err)
        return make_response(str(err), 403)

    @app.errorhandler(RuntimeError)
    @app.errorhandler(ValueError)
    @app.errorhandler(TypeError)
    # pylint: disable=unused-variable
    def input_error(err):
        """Input errors"""
        print "{}: {}".format(type(err).__name__, err)
        import traceback

        traceback.print_exc()
        return make_response(str(err), 400)

    @app.errorhandler(Exception)
    # pylint: disable=unused-variable
    def unknown_error(err):
        """All other exceptions are essentially just raised with logging"""
        print "{}: {}".format(type(err).__name__, err)
        import traceback

        traceback.print_exc()
        return make_response(str(err), 500)

    return app
Example #11
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    # Use prod, or dev database depending on debug mode
    if DEBUG_MODE:
        app.debug = DEBUG_MODE
        app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + TEST_DB
    else:
        app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + DB
    init_db()
    sms_controller = APIController(username=FLOWROUTE_ACCESS_KEY, password=FLOWROUTE_SECRET_KEY)

    # Attach the Flowroute messaging controller to the app
    app.sms_controller = sms_controller
    return app
Example #12
0
def create_app(database_connection):
    app = Flask("Distributed Cuckoo")
    app.config["SQLALCHEMY_DATABASE_URI"] = database_connection
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    app.config["SECRET_KEY"] = os.urandom(32)

    restapi = DistRestApi(app)
    restapi.add_resource(NodeRootApi, "/node")
    restapi.add_resource(NodeApi, "/node/<string:name>")
    restapi.add_resource(StatusRootApi, "/status")

    db.init_app(app)

    with app.app_context():
        db.create_all()

    return app
def create_app(database_uri):
    """
    Create an application with a database in a given location.

    :param database_uri: The location of the database for the application.
    :type database_uri: string
    :return: An application instance.
    :rtype: ``Flask``
    """
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = database_uri
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    db.init_app(app)

    with app.app_context():
        db.create_all()

    return app
Example #14
0
    def setup(self):
        """Creates the Flask application and the APIManager."""
        # create the Flask application
        app = Flask(__name__)
        app.config["DEBUG"] = True
        app.config["TESTING"] = True
        app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
        # This is to avoid a warning in earlier versions of Flask-SQLAlchemy.
        app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
        # This is required by `manager.url_for()` in order to construct
        # absolute URLs.
        app.config["SERVER_NAME"] = "localhost"
        app.logger.disabled = True
        self.flaskapp = app

        # create the test client
        self.app = app.test_client()

        force_json_contenttype(self.app)
Example #15
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config_name)
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True  # suppress SQLAlchemy error
    db.init_app(app)

    from .api import api as api_blueprint

    app.register_blueprint(api_blueprint)

    @app.errorhandler(400)
    def bad_request(error):
        return make_response(jsonify({"error": "400: Recheck your syntax"}), 400)

    @app.errorhandler(404)
    def not_found(error):
        return make_response(jsonify({"error": "404: Resource not found"}), 404)

    return app
Example #16
0
def init_app():
    db_path = "db.sqlite"

    app = Flask(__name__)
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    app.secret_key = "asdfsdfasdf"
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///{}".format(db_path)

    db.init_app(app)
    db.app = app

    from .api import main as api
    from .controllers import main as controllers
    from .auth import main as auth

    app.register_blueprint(controllers)
    app.register_blueprint(api, url_prefix="/api")
    app.register_blueprint(auth)

    return app
Example #17
0
def create_app(config=None, **kw):
    app = Flask(__name__)

    # apply some defaults etc. to the config here
    app.debug = True
    if config is not None:
        app.config.from_pyfile(config)
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.config.update(kw)

    # build the app by mounting extensions & blueprints on it
    # some are part of this app, some are generic
    db.init_app(app)
    generic_db.init_app(app)
    publisher.init_app(app)
    setup_simple(app)

    app.register_blueprint(main)
    app.register_blueprint(thing_views, url_prefix="/things")
    return app
Example #18
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    config[config_name].init_app(app)
    db.init_app(app)
    cache.init_app(app)
    bootstrap.init_app(app)
    login_manager.init_app(app)

    from app.main import main as bp_main

    app.register_blueprint(bp_main)

    from app.authentication import auth as bp_auth

    app.register_blueprint(bp_auth)

    from app.stage import stage as bp_stage

    app.register_blueprint(bp_stage)

    return app
Example #19
0
def create_app(environment_name):
    """Create the actual Flask application."""
    app = Flask(__name__)

    load_config(app, environment_name)

    # Throw an exception when an undefined name is referenced in a template.
    app.jinja_env.undefined = jinja2.StrictUndefined

    # Set the locale.
    set_locale(app.config["LOCALE"])  # Fail if not configured.

    # Add the time zone to the configuration.
    app.config["TIMEZONE"] = TIMEZONE

    # Disable Flask-SQLAlchemy's tracking of object modifications.
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

    # Initialize database.
    db.init_app(app)

    redis.init_app(app)

    email.init_app(app)

    config.init_app(app)

    register_blueprints(app)

    dateformat.register_template_filters(app)
    money.register_template_filters(app)

    app.add_url_rule("/content/<path:filename>", endpoint="content_file", methods=["GET"], build_only=True)

    app.add_url_rule("/content/brand/<path:filename>", endpoint="brand_file", build_only=True)

    return app
Example #20
0
def create_app(config_object=ProdConfig):
    """An application factory, as explained here:
        http://flask.pocoo.org/docs/patterns/appfactories/

    :param config_object: The configuration object to use.
    """
    app = Flask(__name__)
    KVSessionExtension(RedisStore(redis.StrictRedis()), app)
    app.config.from_object(config_object)
    app.config["UPLOAD_FOLDER"] = "uploads"
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    register_extensions(app)
    register_blueprints(app)
    register_errorhandlers(app)
    ALLOWED_EXTENSIONS = ["txt", "pdf", "png", "jpg", "jpeg"]

    #    app.config['UPLOADED_PHOTOS_DEST'] = '/tmp/testuploadext'
    #    upload_user_image = UploadSet('user_image', IMAGES)
    #    upload_poster_image = UploadSet('user_poster', IMAGES)
    #    configure_uploads(app, photos)

    moment = Moment(app)
    # sslify = SSLify(app)
    return app
Example #21
0
        logger.addHandler(handler)
        logger.setLevel(log_level)


from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

# Create Flask application
application = Flask("web")
if os.environ.get("JARR_TESTING", False) == "true":
    application.debug = logging.DEBUG
    application.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
    application.config["TESTING"] = True
else:
    application.debug = conf.LOG_LEVEL <= logging.DEBUG
    application.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    application.config["SQLALCHEMY_DATABASE_URI"] = conf.SQLALCHEMY_DATABASE_URI

scheme, domain, _, _, _ = urlsplit(conf.PLATFORM_URL)
application.config["SERVER_NAME"] = domain
application.config["PREFERRED_URL_SCHEME"] = scheme

set_logging(conf.LOG_PATH, log_level=conf.LOG_LEVEL)

# Create secrey key so we can use sessions
application.config["SECRET_KEY"] = os.urandom(12)

application.config["RECAPTCHA_USE_SSL"] = True
application.config["RECAPTCHA_PUBLIC_KEY"] = conf.RECAPTCHA_PUBLIC_KEY
application.config["RECAPTCHA_PRIVATE_KEY"] = conf.RECAPTCHA_PRIVATE_KEY
Example #22
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand


flask_app = Flask(__name__)
flask_app.secret_key = "fhdjksfh7h38h3489fh3489fh3489hf938h"

# app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://ipostolaki@localhost/Books'
flask_app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///books.db"
flask_app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

db = SQLAlchemy(flask_app)
migrate = Migrate(flask_app, db)

manager = Manager(flask_app)
manager.add_command("db", MigrateCommand)


@flask_app.route("/")
def index():
    return "This flask app will be used to view simulation data stored in the database"


#### ORM Storage Models


class StoredBook(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80))
Example #23
0
from flask.ext.bootstrap import Bootstrap
from flask.ext.wtf import Form
from wtforms import StringField, SubmitField
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
import sqlite3
import os

app = Flask(__name__)
bootstrap = Bootstrap(app)

app.config["SECRET_KEY"] = "i dont know"
basedir = os.path.abspath(os.path.dirname(__file__))
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "test.s3db")
app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True

db = SQLAlchemy(app)

# 定义模型
class Role(db.Model):
    __tablename__ = "roles"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    users = db.relationship("User", backref="role")

    def __repr__(self):
        return "<Role %r>" % self.name


class User(db.Model):
Example #24
0
    def setUp(self):
        self.db = SQLAlchemy()
        self.wh = Whooshee()
        for a in ["app1", "app2"]:
            app = Flask(a)
            app.config["WHOOSHEE_DIR"] = tempfile.mkdtemp()
            app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
            app.config["TESTING"] = True
            app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
            self.db.init_app(app)
            self.wh.init_app(app)
            setattr(self, a, app)

        class User(self.db.Model):
            id = self.db.Column(self.db.Integer, primary_key=True)
            name = self.db.Column(self.db.String)

        # separate index for just entry
        @self.wh.register_model("title", "content")
        class Entry(self.db.Model):
            id = self.db.Column(self.db.Integer, primary_key=True)
            title = self.db.Column(self.db.String)
            content = self.db.Column(self.db.Text)
            user = self.db.relationship(User, backref=self.db.backref("entries"))
            user_id = self.db.Column(self.db.Integer, self.db.ForeignKey("user.id"))

        # index for both entry and user
        @self.wh.register_whoosheer
        class EntryUserWhoosheer(AbstractWhoosheer):
            schema = whoosh.fields.Schema(
                entry_id=whoosh.fields.NUMERIC(stored=True, unique=True),
                user_id=whoosh.fields.NUMERIC(stored=True),
                username=whoosh.fields.TEXT(),
                title=whoosh.fields.TEXT(),
                content=whoosh.fields.TEXT(),
            )

            models = [Entry, User]

            @classmethod
            def update_user(cls, writer, user):
                pass  # TODO: update all users entries

            @classmethod
            def update_entry(cls, writer, entry):
                writer.update_document(
                    entry_id=entry.id,
                    user_id=entry.user.id,
                    username=entry.user.name,
                    title=entry.title,
                    content=entry.content,
                )

            @classmethod
            def insert_user(cls, writer, user):
                # nothing, user doesn't have entries yet
                pass

            @classmethod
            def insert_entry(cls, writer, entry):
                writer.add_document(
                    entry_id=entry.id,
                    user_id=entry.user.id,
                    username=entry.user.name,
                    title=entry.title,
                    content=entry.content,
                )

            @classmethod
            def delete_user(cls, writer, user):
                # nothing, user doesn't have entries yet
                pass

            @classmethod
            def delete_entry(cls, writer, entry):
                writer.delete_by_term("entry_id", entry.id)

        self.User = User
        self.Entry = Entry
        self.EntryUserWhoosheer = EntryUserWhoosheer

        self.db.create_all(app=self.app1)
        self.db.create_all(app=self.app2)

        self.u1 = User(name=u"chuck")
        self.u2 = User(name=u"arnold")
        self.u3 = User(name=u"silvester")

        self.e1 = Entry(title=u"chuck nr. 1 article", content=u"blah blah blah", user=self.u1)
        self.e2 = Entry(title=u"norris nr. 2 article", content=u"spam spam spam", user=self.u1)
        self.e3 = Entry(title=u"arnold blah", content=u"spam is cool", user=self.u2)
        self.e4 = Entry(title=u"the less dangerous", content=u"chuck is better", user=self.u3)

        self.all_inst = [self.u1, self.u2, self.u3, self.e1, self.e2, self.e3, self.e4]
Example #25
0
    "newrelic",
    "RateLimiter",
]

for a_library in libraries_to_mum:
    the_logger = logging.getLogger(a_library)
    the_logger.setLevel(logging.WARNING)
    the_logger.propagate = True

requests.packages.urllib3.disable_warnings()

app = Flask(__name__)
# app.debug = True

# database stuff
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True  # as instructed, to supress warning
app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL")
app.config["SQLALCHEMY_POOL_SIZE"] = 60
app.config["SQLALCHEMY_ECHO"] = os.getenv("SQLALCHEMY_ECHO", False) == "True"
db = SQLAlchemy(app)

# do compression.  has to be above flask debug toolbar so it can override this.
compress_json = os.getenv("COMPRESS_DEBUG", "False") == "True"


# set up Flask-DebugToolbar
if os.getenv("FLASK_DEBUG", False) == "True":
    logger.info("Setting app.debug=True; Flask-DebugToolbar will display")
    compress_json = False
    app.debug = True
    app.config["DEBUG"] = True
Example #26
0
File: blog.py Project: alxhrck/blog
import glob
import markdown
import collections
from flask import Flask
from flask import render_template
from flask import Markup
from flask import url_for
from flask import redirect
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime


app = Flask(__name__)
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False  # If not needed. If set to True uses more memory
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///blog.db"
db = SQLAlchemy(app)


class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime)
    title = db.Column(db.String(80), unique=True)
    text = db.Column(db.Text)

    def __init__(self, date, title, text):
        self.date = date
        self.title = title
        self.text = text

    def __repr__(self):
        return "<Title %r>" % self.title
Example #27
0
@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()


def sessionAdd(obj):
    try:
        db_session.merge(obj)
        db_session.flush()
    except IntegrityError:
        db_session.rollback()


# Setup database
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False  # To suppress warning, can set to True if needed in future


# API -------------------------------------------------------------------------


# Setup API
api = Api(app)


class ViewControllerListAPI(Resource):

    """Returns a list of all supported ViewControllers

    Not really a necessary API call, but was simple to implement and return a
    set list of static information to test the API and database.
Example #28
0
File: app.py Project: kryptn/slnky
from flask import Flask, redirect, url_for
from flask_restful import Resource, Api
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///slnky.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True  # to suppress an obnoxious warning
app.config["ERROR_404_HELP"] = False
db = SQLAlchemy(app)
api = Api(app)


class Links(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    slug = db.Column(db.String, unique=True)
    url = db.Column(db.String)

    def __init__(self, url):
        self.url = url

    def slughash(self, key):
        return str(key)

    @property
    def slug_url(self):
        return api.url_for(Redirector, slug=self.slug, _external=True)

    def serialize(self):
        return {"id": self.id, "url": self.url, "slug": self.slug, "slug_url": self.slug_url}

    @staticmethod
Example #29
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(frontendconf["FLASKCONFIG"])
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    db.init_app(app)
    return app
Example #30
0
    BaseMixin,
    BaseNameMixin,
    BaseScopedNameMixin,
    BaseIdNameMixin,
    BaseScopedIdMixin,
    BaseScopedIdNameMixin,
    JsonDict,
    failsafe_add,
)
from coaster.db import db


app1 = Flask(__name__)
app1.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
app1.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app2 = Flask(__name__)
app2.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://:@localhost:5432/coaster_test"
app2.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.init_app(app1)
db.init_app(app2)


# --- Models ------------------------------------------------------------------
class BaseContainer(db.Model):
    __tablename__ = "base_container"
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(80), nullable=True)


class Container(BaseMixin, db.Model):
    __tablename__ = "container"
    name = Column(Unicode(80), nullable=True)