langchain.chains.sql_database.query.create_sql_query_chain¶
- langchain.chains.sql_database.query.create_sql_query_chain(llm: BaseLanguageModel, db: SQLDatabase, prompt: Optional[BasePromptTemplate] = None, k: int = 5) RunnableSequence[Union[SQLInput, SQLInputWithTables], str][source]¶
Create a chain that generates SQL queries.
- Parameters
llm – The language model to use
db – The SQLDatabase to generate the query for
prompt – The prompt to use. If none is provided, will choose one based on dialect. Defaults to None.
k – The number of results per select statement to return. Defaults to 5.
- Returns
A chain that takes in a question and generates a SQL query that answers that question.