

@utils.memoize
def __getitem__(self, name):
    if ('DATABASES' not in settings):
        raise exceptions.ImproperlyConfigured('DATABASES not configured in project settings.')
    if (name not in settings['DATABASES']):
        raise exceptions.ImproperlyConfigured(('%r not present in DATABASES configuration.' % name))
    config = settings['DATABASES'][self]
    if isinstance(config, six.string_types):
        url = make_url(config)
        options = {
            
        }
    else:
        config = dict(map((lambda i: (i[0].lower(), i[1])), config.items()))
        options = config.get('options', {
            
        })
        url = URL(config['engine'], username=config.get('username', config.get('user')), password=config.get('password', config.get('pass')), host=config.get('hostname', config.get('host')), port=config.get('port'), database=config.get('name', config.get('database')))
    if settings['TESTING']:
        if url.drivername.startswith('sqlite'):
            url.database = ':memory:'
        else:
            ident = threading.current_thread().ident
            url.database = ('test_%s_%s' % (url.database, ident))
    pool_size = None
    pool_recycle = None
    if url.drivername.startswith('mysql'):
        pool_size = 10
        pool_recycle = 7200
    pool_size = settings.get('DATABASE_POOL_SIZE', pool_size)
    if pool_size:
        options.setdefault('pool_size', pool_size)
    pool_recycle = settings.get('DATABASE_POOL_RECYCLE', pool_recycle)
    if pool_recycle:
        options.setdefault('pool_recycle', pool_recycle)
    pool_timeout = settings.get('DATABASE_POOL_TIMEOUT')
    if pool_timeout:
        options.setdefault('pool_timeout', pool_timeout)
    engine = sa.create_engine(url, **options)
    if settings['DEBUG']:
        from sqlalchemy.event import listen
        listen(engine, 'after_cursor_execute', (lambda *a, **kw: None))
    return engine

dataset/ETHPy150Open concordusapps/alchemist/alchemist/db/_engine.py Engine.__getitem__/VarMisuse@69/116 `name`->`self`