How to use the aldjemy.core.Cache.engines 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 Deepwalker / aldjemy / aldjemy / core.py View on Github external
def get_engine(alias='default'):
    if alias not in Cache.engines:
        engine_string = get_engine_string(alias)
        # we have to use autocommit=True, because SQLAlchemy
        # is not aware of Django transactions
        kw = {}
        if engine_string == 'sqlite3':
            kw['native_datetime'] = True

        pool = DjangoPool(alias=alias, creator=None)
        Cache.engines[alias] = create_engine(get_connection_string(alias),
                                             pool=pool, **kw)
    return Cache.engines[alias]