Which method is used to create a connection object between a Python script and…
2026
Which method is used to create a connection object between a Python script and a MySQL database assuming that the module pymysql is imported?
- A.
pymysql.open()
- B.
pymysql.connect()
- C.
pymysql.link()
- D.
pymysql.join()
Attempted by 119 students.
Show answer & explanation
Correct answer: B
To create a connection object between a Python script and a MySQL database using the pymysql module, you must use the connect() function. The correct syntax is pymysql.connect(). Other methods such as open(), link(), or join() are not part of the pymysql API for establishing database connections.