langchain/chains/loading.py/_load_sql_database_chain
def _load_sql_database_chain(config: dict, **kwargs: Any) -> SQLDatabaseChain:
    if "database" in kwargs:
        database = kwargs.pop("database")
    else:
        raise ValueError("`database` must be present.")
    if "llm" in config:
        llm_config = config.pop("llm")
        llm = load_llm_from_config(llm_config)
    elif "llm_path" in config:
        llm = load_llm(config.pop("llm_path"))
    else:
        raise ValueError("One of `llm` or `llm_path` must be present.")
    if "prompt" in config:
        prompt_config = config.pop("prompt")
        prompt = load_prompt_from_config(prompt_config)
    else:
        prompt = None
    return SQLDatabaseChain.from_llm(llm, database, prompt=prompt, **config)