Ejemplo n.º 1
0
def init_model(junk=None):
    # Connect.
    new_engine()

    # Import models.
    import_models()

    # Setup elixir entities.
    setup_all()

    # Bind session to the engine.
    Session.configure(bind=_engine)
Ejemplo n.º 2
0
def init_model(junk=None):
    # Connect.
    new_engine()

    # Import models.
    import_models()

    # Setup elixir entities.
    setup_all()

    # Bind session to the engine.
    Session.configure(bind=_engine)
Ejemplo n.º 3
0
def init_local():
    # Change session engine bind, if needed.
    if Session.get_bind(None) != _engine:
        log.debug("init_local(): [Re-]configuring session bind.")
        Session.configure(bind=_engine)

    # Detect stale pool database connections.
    # In case of failure, the pool will reconnect automatically.
    # This is not needed when using only models, but it is needed when using either the engine
    # or the session directly to do raw queries.
    try:
        Session.execute("SELECT 1")

    except OperationalError, e:
        if getattr(e, 'connection_invalidated') and e.connection_invalidated:
            log.warn("init_local(): database connection was invalidated.")
        else:
            log.warn("init_local(): database exception: '%s'." % (str(e)))
Ejemplo n.º 4
0
def init_local():
    # Change session engine bind, if needed.
    if Session.get_bind(None) != _engine:
        log.debug("init_local(): [Re-]configuring session bind.")
        Session.configure(bind=_engine)

    # Detect stale pool database connections.
    # In case of failure, the pool will reconnect automatically.
    # This is not needed when using only models, but it is needed when using either the engine
    # or the session directly to do raw queries.
    try:
        Session.execute("SELECT 1")

    except OperationalError, e:
        if getattr(e, 'connection_invalidated') and e.connection_invalidated:
            log.warn("init_local(): database connection was invalidated.")
        else:
            log.warn("init_local(): database exception: '%s'." % ( str(e) ) )
Ejemplo n.º 5
0
def reset_thread_local_session():
    Session.remove()
Ejemplo n.º 6
0
def reset_thread_local_session():
    Session.remove()