Skip to main contentSkip to solution

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

✅ Correct Option: 1

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question