SQL Query Engine
Default query for SQLStructStoreIndex.
- class llama_index.indices.struct_store.sql_query.BaseSQLTableQueryEngine(sql_database: SQLDatabase, text_to_sql_prompt: Optional[BasePromptTemplate] = None, context_query_kwargs: Optional[dict] = None, synthesize_response: bool = True, response_synthesis_prompt: Optional[BasePromptTemplate] = None, service_context: Optional[ServiceContext] = None, **kwargs: Any)
- property service_context: ServiceContext
Get service context.
- llama_index.indices.struct_store.sql_query.GPTNLStructStoreQueryEngine
alias of
NLStructStoreQueryEngine
- llama_index.indices.struct_store.sql_query.GPTSQLStructStoreQueryEngine
alias of
SQLStructStoreQueryEngine
- class llama_index.indices.struct_store.sql_query.NLSQLTableQueryEngine(sql_database: SQLDatabase, text_to_sql_prompt: Optional[BasePromptTemplate] = None, context_query_kwargs: Optional[dict] = None, synthesize_response: bool = True, response_synthesis_prompt: Optional[BasePromptTemplate] = None, tables: Optional[Union[List[str], List[Table]]] = None, service_context: Optional[ServiceContext] = None, **kwargs: Any)
NL SQL Table query engine.
- property service_context: ServiceContext
Get service context.
- class llama_index.indices.struct_store.sql_query.NLStructStoreQueryEngine(index: SQLStructStoreIndex, text_to_sql_prompt: Optional[BasePromptTemplate] = None, context_query_kwargs: Optional[dict] = None, synthesize_response: bool = True, response_synthesis_prompt: Optional[BasePromptTemplate] = None, **kwargs: Any)
GPT natural language query engine over a structured database.
NOTE: deprecated, kept for backward compatibility
Given a natural language query, we will extract the query to SQL. Runs raw SQL over a SQLStructStoreIndex. No LLM calls are made during the SQL execution. NOTE: this query cannot work with composed indices - if the index contains subindices, those subindices will not be queried.
- Parameters
index (SQLStructStoreIndex) – A SQL Struct Store Index
text_to_sql_prompt (Optional[BasePromptTemplate]) – A Text to SQL BasePromptTemplate to use for the query. Defaults to DEFAULT_TEXT_TO_SQL_PROMPT.
context_query_kwargs (Optional[dict]) – Keyword arguments for the context query. Defaults to {}.
synthesize_response (bool) – Whether to synthesize a response from the query results. Defaults to True.
response_synthesis_prompt (Optional[BasePromptTemplate]) – A Response Synthesis BasePromptTemplate to use for the query. Defaults to DEFAULT_RESPONSE_SYNTHESIS_PROMPT.
- property service_context: ServiceContext
Get service context.
- class llama_index.indices.struct_store.sql_query.SQLStructStoreQueryEngine(index: SQLStructStoreIndex, sql_context_container: Optional[SQLContextContainerBuilder] = None, **kwargs: Any)
GPT SQL query engine over a structured database.
NOTE: deprecated, kept for backward compatibility
Runs raw SQL over a SQLStructStoreIndex. No LLM calls are made here. NOTE: this query cannot work with composed indices - if the index contains subindices, those subindices will not be queried.
- class llama_index.indices.struct_store.sql_query.SQLTableRetrieverQueryEngine(sql_database: SQLDatabase, table_retriever: ObjectRetriever[SQLTableSchema], text_to_sql_prompt: Optional[BasePromptTemplate] = None, context_query_kwargs: Optional[dict] = None, synthesize_response: bool = True, response_synthesis_prompt: Optional[BasePromptTemplate] = None, service_context: Optional[ServiceContext] = None, context_str_prefix: Optional[str] = None, **kwargs: Any)
SQL Table retriever query engine.
- property service_context: ServiceContext
Get service context.