For example:Loading a CSV fileLoading a Pandas DataFrame
Here you can check full list of Document LoadersCase 1: Text-to-SQL query‚Äãfrom langchain.chat_models import ChatOpenAIfrom langchain.chains import create_sql_query_chainLet's create the chain that will build the SQL Query:chain = create_sql_query_chain(ChatOpenAI(temperature=0), db)response = chain.invoke({"question":"How many employees are there"})print(response)    SELECT COUNT(*) FROM EmployeeAfter building the SQL query based on a user question, we can execute the query:db.run(response)    '[(8,)]'As we can see, the SQL Query Builder chain only created the query, and we handled the query execution separately.Go deeper‚ÄãLooking under the hoodWe can look at the LangSmith trace to unpack this:Some papers have reported good performance when prompting with:A CREATE TABLE description for each table, which include column names, their types, etcFollowed by three example rows in a SELECT statementcreate_sql_query_chain adopts this the best practice (see more in this blog).
Open In Colab
Open In Colab ->: For example:Loading a CSV fileLoading a Pandas DataFrame
Here you can check full list of Document LoadersCase 1: Text-to-SQL query‚Äãfrom langchain.chat_models import ChatOpenAIfrom langchain.chains import create_sql_query_chainLet's create the chain that will build the SQL Query:chain = create_sql_query_chain(ChatOpenAI(temperature=0), db)response = chain.invoke({"question":"How many employees are there"})print(response)    SELECT COUNT(*) FROM EmployeeAfter building the SQL query based on a user question, we can execute the query:db.run(response)    '[(8,)]'As we can see, the SQL Query Builder chain only created the query, and we handled the query execution separately.Go deeper‚ÄãLooking under the hoodWe can look at the LangSmith trace to unpack this:Some papers have reported good performance when prompting with:A CREATE TABLE description for each table, which include column names, their types, etcFollowed by three example rows in a SELECT statementcreate_sql_query_chain adopts this the best practice (see more in this blog).