Arrange the steps required to read data from a MySQL database to a DataFrame:
A. pip install pymysql
B. pip install sqlalchemy
C. pandas.read_sql_query(query,sql_conn)
D. engine=create_engine('driver:// username:password@host:port/name_of_database',index=false)
Arrange the steps required to read data from a MySQL database to a DataFrame:
A. pip install pymysql
B. pip install sqlalchemy
C. pandas.read_sql_query(query,sql_conn)
D. engine=create_engine('driver:// username:password@host:port/name_of_database',index=false)
Solution
A. pip install pymysql: installs the MySQL driver that Python uses to talk to the database.
B. pip install sqlalchemy: installs the library that creates the connection engine.
D. engine=create_engine(...): builds the connection to the MySQL database, which needs both packages installed first.
C. pandas.read_sql_query(query,sql_conn): runs the query on that connection and returns the result as a DataFrame.
Options 2 and 4: C cannot come before D, because the query needs an existing connection to run on.
Related questions:
2026: 21 May Shift 1
2025: 13 May Shift 2
2026: 29 May Shift 1