Question:

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: Sep 18, 2025
  • (A), (B) and (D) only
  • (A), (B) and (C) only
  • (A), (B), (C) and (D)
  • (B), (C) and (D) only
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Understanding the functions in pandas for SQL.
Pandas provides multiple functions to fetch data from SQL into DataFrames:

pandas.read__sql__query(): Used when you want to run a SQL query string and get the result as a DataFrame.
pandas.read__sql__table(): Directly reads an entire SQL table into a DataFrame.
pandas.read__sql(): A flexible function that can take either a query or a table name as an argument.

Step 2: Checking validity of each option.
- Option (A): Correct. Commonly used for executing queries.
- Option (B): Correct. Used for fetching the entire table.
- Option (C): Incorrect. \texttt{read__sql__query__table()} does not exist in pandas.
- Option (D): Correct. A flexible option for both queries and tables.

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

Questions Asked in CUET exam

View More Questions