Mandatory arguments required to connect any database from Python

(A) Username, Password, Hostname, Database Name, Port.

(B) Username, Password, Hostname.

(C) Username, Password, Hostname, Database Name.

(D) Username, Password, Hostname, Port.

 

Answer:

To create a connection between the MySQL database and python application, the connect( ) function is used. The functions requires 4 parameters:

  • Hostname
  • Username
  • Password 
  • Database name

Checking the options

  • (A) Username, Password, Hostname, Database  Name, Port. - Port is not a parameter of the function connect( ).
  • (B) Username, Password, Hostname. - The parameter database name is missing.  
  • (C) Username, Password, Hostname, Database  Name. - All 4 parameters of the function connect( ) are present. 
  • (D) Username, Password, Hostname, Port. - Port is not a valid parameter and the parameter database name is missing.  

 

From the options given above, only option C has all the 4 parameters of function connect( ).

So, the correct answer is (C)

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.