How to use the aldjemy.core.get_engine function in aldjemy

To help you get started, we’ve selected a few aldjemy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Deepwalker / aldjemy / test_project / sample / tests.py View on Github external
def test_engines_cache(self):
        from aldjemy.core import Cache, get_engine

        self.assertEqual(get_engine('default'), Cache.engines['default'])
        self.assertEqual(get_engine('logs'), Cache.engines['logs'])
        self.assertEqual(get_engine(), Cache.engines['default'])
        self.assertNotEqual(get_engine('default'), get_engine('logs'))
github aiidateam / aiida-core / aiida / backends / djsite / querybuilder_django / dummy_model.py View on Github external
def get_aldjemy_session():
    """
    Use aldjemy to make a session

    .. note:
        Use only in this case. In normal production mode
        it is safer make session explictly because it is more robust
    """
    from aldjemy.core import get_engine
    engine = get_engine()
    _Session = sessionmaker(bind=engine)
    return _Session()
github Deepwalker / aldjemy / aldjemy / orm.py View on Github external
def get_session(alias='default'):
    connection = connections[alias]
    if not hasattr(connection, 'sa_session'):
        session = orm.sessionmaker(bind=get_engine(alias))
        connection.sa_session = session()
    return connection.sa_session
github Deepwalker / aldjemy / aldjemy / orm.py View on Github external
def get_session(alias='default', recreate=False):
    connection = connections[alias]
    if not hasattr(connection, 'sa_session') or recreate:
        engine = get_engine(alias)
        session = orm.sessionmaker(bind=engine)
        connection.sa_session = session()
    return connection.sa_session
github aiidateam / aiida-core / aiida / orm / implementation / django / dummy_model.py View on Github external
def get_aldjemy_session():
    """
    Use aldjemy to make a session

    .. note:
        Use only in this case. In normal production mode
        it is safer make session explictly because it is more robust
    """
    from aldjemy.core import get_engine
    engine = get_engine()
    _Session = sessionmaker(bind=engine)
    return _Session()