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)