# Path: cliche/orm.py
# def make_repr(self):
# def get_alembic_config(engine):
# def initialize_database(engine):
# def get_database_revision(engine):
#     def get_revision(rev, context):
# def upgrade_database(engine, revision='head'):
#     def upgrade(rev, context):
#         def update_current_rev(old, new):
# def downgrade_database(engine, revision):
# def import_all_modules(dry_run=False):  # FIXME


from flask import current_app, g, _app_ctx_stack
from sqlalchemy import create_engine
from werkzeug.local import LocalProxy
from ..orm import Session
        db_url = config['DATABASE_URL']
        engine = create_engine(db_url, **get_database_engine_options())
        config['DATABASE_ENGINE'] = engine
        return engine


def get_database_engine_options():
    """Get a dictionary of options for SQLAlchemy engine.  These options
    are used by :func:`get_database_engine()` and passed to
    :func:`sqlalchemy.create_engine()` function.

    """
    return {}


def get_session():
    """Get a session.  If there's no yet, create one.

    :returns: a session
    :rtype: :class:`~cliche.orm.Session`

    """
    try:
        app_ctx_session = _app_ctx_stack.top.session
    except (AttributeError, RuntimeError):
        pass
    else:
        return app_ctx_session
    if hasattr(g, 'session'):
        return g.session

# Path: cliche/orm.py
# def make_repr(self):
# def get_alembic_config(engine):
# def initialize_database(engine):
# def get_database_revision(engine):
#     def get_revision(rev, context):
# def upgrade_database(engine, revision='head'):
#     def upgrade(rev, context):
#         def update_current_rev(old, new):
# def downgrade_database(engine, revision):
# def import_all_modules(dry_run=False):  # FIXME


# Path: cliche/web/db.py
from flask import current_app, g, _app_ctx_stack
from sqlalchemy import create_engine
from werkzeug.local import LocalProxy
from ..orm import Session

        db_url = config['DATABASE_URL']
        engine = create_engine(db_url, **get_database_engine_options())
        config['DATABASE_ENGINE'] = engine
        return engine


def get_database_engine_options():
    """Get a dictionary of options for SQLAlchemy engine.  These options
    are used by :func:`get_database_engine()` and passed to
    :func:`sqlalchemy.create_engine()` function.

    """
    return {}


def get_session():
    """Get a session.  If there's no yet, create one.

    :returns: a session
    :rtype: :class:`~cliche.orm.Session`

    """
    try:
        app_ctx_session = _app_ctx_stack.top.session
    except (AttributeError, RuntimeError):
        pass
    else:
        return app_ctx_session
    if hasattr(g, 'session'):
        return g.session

    sess = Session(bind=get_database_engine())