Question:medium

After establishing the connection to fetch the data from the table of a database in SQL into a DataFrame, which of the following function will be used?
(A) pandas.read__sql__query()
(B) pandas.read__sql__table()
(C) pandas.read__sql__query__table()
(D) pandas.read__sql()

Show Hint

Remember: \texttt{read__sql__query()} → for queries, \texttt{read__sql__table()} → for full tables, and \texttt{read__sql()} → for both. Ignore non-existent functions like \texttt{read__sql__query__table()}.
Updated On: Feb 16, 2026
  • (A), (B) and (D) only
  • (A), (B) and (C) only
  • (A), (B), (C) and (D)
  • (B), (C) and (D) only
Show Solution

The Correct Option is A

Solution and Explanation

Step 1: Pandas Functions for SQL Data Fetching.
Pandas offers several functions to import data from SQL into DataFrames:

pandas.read_sql_query(): Executes a SQL query and returns the results as a DataFrame.
pandas.read_sql_table(): Imports an entire SQL table directly into a DataFrame.
pandas.read_sql(): A versatile function that accepts either a query string or a table name.

Step 2: Evaluating Options.
- Option (A): Valid. Suitable for executing queries.
- Option (B): Valid. Designed for importing complete tables.
- Option (C): Invalid. The function \texttt{read_sql_query_table()} does not exist in pandas.
- Option (D): Valid. A flexible function accommodating both queries and tables.

Step 3: Conclusion.
Therefore, the correct functions are (A), (B), and (D).
Final Answer: \[\boxed{(A), (B) \text{ and } (D) \text{ only}}\]
Was this answer helpful?
0