src/pybel/manager/base_manager.py
def build_engine_session(
    connection: str,
    echo: bool = False,
    autoflush: Optional[bool] = None,
    autocommit: Optional[bool] = None,
    expire_on_commit: Optional[bool] = None,
    scopefunc=None,
) -> Tuple:
    """Build an engine and a session.

    :param connection: An RFC-1738 database connection string
    :param echo: Turn on echoing SQL
    :param autoflush: Defaults to True if not specified in kwargs or configuration.
    :param autocommit: Defaults to False if not specified in kwargs or configuration.
    :param expire_on_commit: Defaults to False if not specified in kwargs or configuration.
    :param scopefunc: Scoped function to pass to :func:`sqlalchemy.orm.scoped_session`
    :rtype: tuple[Engine,Session]

    From the Flask-SQLAlchemy documentation:

    An extra key ``'scopefunc'`` can be set on the ``options`` dict to
    specify a custom scope function.  If it's not provided, Flask's app
    context stack identity is used. This will ensure that sessions are
    created and removed with the request/response cycle, and should be fine
    in most cases.
    """
    if connection is None:
        raise ValueError('can not build engine when connection is None')

    engine = create_engine(connection, echo=echo)

    autoflush = pystow.get_config('pybel', 'manager_autoflush', passthrough=autoflush, dtype=bool, default=True)
    autocommit = pystow.get_config('pybel', 'manager_autocommit', passthrough=autocommit, dtype=bool, default=False)
    expire_on_commit = pystow.get_config(
        'pybel', 'manager_autoexpire', passthrough=expire_on_commit, dtype=bool, default=True,
    )

    logger.debug('auto flush: %s, auto commit: %s, expire on commmit: %s', autoflush, autocommit, expire_on_commit)

    #: A SQLAlchemy session maker
    session_maker = sessionmaker(
        bind=engine,
        autoflush=autoflush,
        autocommit=autocommit,
        expire_on_commit=expire_on_commit,
    )

    #: A SQLAlchemy session object
    session = scoped_session(
        session_maker,
        scopefunc=scopefunc,
    )

    return engine, session
Build an engine and a session.

    :param connection: An RFC-1738 database connection string
    :param echo: Turn on echoing SQL
    :param autoflush: Defaults to True if not specified in kwargs or configuration.
    :param autocommit: Defaults to False if not specified in kwargs or configuration.
    :param expire_on_commit: Defaults to False if not specified in kwargs or configuration.
    :param scopefunc: Scoped function to pass to :func:`sqlalchemy.orm.scoped_session`
    :rtype: tuple[Engine,Session]

    From the Flask-SQLAlchemy documentation:

    An extra key ``'scopefunc'`` can be set on the ``options`` dict to
    specify a custom scope function.  If it's not provided, Flask's app
    context stack identity is used. This will ensure that sessions are
    created and removed with the request/response cycle, and should be fine
    in most cases.
    
Build an engine and a session.
Build an engine and a session .
def build_engine_session(
    connection: str,
    echo: bool = False,
    autoflush: Optional[bool] = None,
    autocommit: Optional[bool] = None,
    expire_on_commit: Optional[bool] = None,
    scopefunc=None,
) -> Tuple:
    if connection is None:
        raise ValueError('can not build engine when connection is None')
    engine = create_engine(connection, echo=echo)
    autoflush = pystow.get_config('pybel', 'manager_autoflush', passthrough=autoflush, dtype=bool, default=True)
    autocommit = pystow.get_config('pybel', 'manager_autocommit', passthrough=autocommit, dtype=bool, default=False)
    expire_on_commit = pystow.get_config(
        'pybel', 'manager_autoexpire', passthrough=expire_on_commit, dtype=bool, default=True,
    )
    logger.debug('auto flush: %s, auto commit: %s, expire on commmit: %s', autoflush, autocommit, expire_on_commit)
    session_maker = sessionmaker(
        bind=engine,
        autoflush=autoflush,
        autocommit=autocommit,
        expire_on_commit=expire_on_commit,
    )
    session = scoped_session(
        session_maker,
        scopefunc=scopefunc,
    )
    return engine, session
def build_engine_session ( connection : str , echo : bool = False , autoflush : Optional [ bool ] = None , autocommit : Optional [ bool ] = None , expire_on_commit : Optional [ bool ] = None , scopefunc = None , ) -> Tuple : if connection is None : raise ValueError ( 'can not build engine when connection is None' ) engine = create_engine ( connection , echo = echo ) autoflush = pystow . get_config ( 'pybel' , 'manager_autoflush' , passthrough = autoflush , dtype = bool , default = True ) autocommit = pystow . get_config ( 'pybel' , 'manager_autocommit' , passthrough = autocommit , dtype = bool , default = False ) expire_on_commit = pystow . get_config ( 'pybel' , 'manager_autoexpire' , passthrough = expire_on_commit , dtype = bool , default = True , ) logger . debug ( 'auto flush: %s, auto commit: %s, expire on commmit: %s' , autoflush , autocommit , expire_on_commit ) session_maker = sessionmaker ( bind = engine , autoflush = autoflush , autocommit = autocommit , expire_on_commit = expire_on_commit , ) session = scoped_session ( session_maker , scopefunc = scopefunc , ) return engine , session
Build an engine and a session.
Build an engine and a session .
"""Build an engine and a session.

    :param connection: An RFC-1738 database connection string
    :param echo: Turn on echoing SQL
    :param autoflush: Defaults to True if not specified in kwargs or configuration.
    :param autocommit: Defaults to False if not specified in kwargs or configuration.
    :param expire_on_commit: Defaults to False if not specified in kwargs or configuration.
    :param scopefunc: Scoped function to pass to :func:`sqlalchemy.orm.scoped_session`
    :rtype: tuple[Engine,Session]

    From the Flask-SQLAlchemy documentation:

    An extra key ``'scopefunc'`` can be set on the ``options`` dict to
    specify a custom scope function.  If it's not provided, Flask's app
    context stack identity is used. This will ensure that sessions are
    created and removed with the request/response cycle, and should be fine
    in most cases.
    """ #: A SQLAlchemy session maker #: A SQLAlchemy session object
None
tuple[Engine,Session]
From the Flask-SQLAlchemy documentation:

An extra key ``'scopefunc'`` can be set on the ``options`` dict to
specify a custom scope function.  If it's not provided, Flask's app
context stack identity is used. This will ensure that sessions are
created and removed with the request/response cycle, and should be fine
in most cases.
connection
str
An RFC-1738 database connection string
An RFC - 1738 database connection string
echo
bool
Turn on echoing SQL
Turn on echoing SQL
autoflush
Optional[bool]
Defaults to True if not specified in kwargs or configuration.
Defaults to True if not specified in kwargs or configuration .
autocommit
Optional[bool]
Defaults to False if not specified in kwargs or configuration.
Defaults to False if not specified in kwargs or configuration .
expire_on_commit
Optional[bool]
Defaults to False if not specified in kwargs or configuration.
Defaults to False if not specified in kwargs or configuration .
scopefunc
Scoped function to pass to :func:`sqlalchemy.orm.scoped_session`
Scoped function to pass to : func : ` sqlalchemy . orm . scoped_session `