Quiz on Database Access in Python
FREE Online Courses: Your Passport to Excellence - Start Now
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which of the following is not the module provided by Python to connect with MySQL?
CorrectIncorrect -
Question 2 of 15
2. Question
Which of the following commands is used to stop the connection between Python and Mysql?
CorrectIncorrect -
Question 3 of 15
3. Question
Arrange the below steps in order to communicate with the database?
1. Get connection object using the connect()
2. Use the execute() function by passing query
3. Call the cursor() method
CorrectIncorrect -
Question 4 of 15
4. Question
What does ‘R’ mean in CRUD?
CorrectIncorrect -
Question 5 of 15
5. Question
What does the below code do?
import mysql.connector
db=mysql.connector.connect(user=”root”,passwd=”1234″,host=”localhost”)
my_cursor=db.cursor()
my_cursor.execute(“CREATE DATABASE db”)
db=mysql.connector.connect(user=”root”,passwd=”1234″,host=”localhost”,database=’d_b’)
my_cursor=db.cursor()
query=”CREATE TABLE food”
my_cursor.execute(query)
CorrectIncorrect -
Question 6 of 15
6. Question
Which of the following is the correct code to add a column named ‘clmn’ to the table ‘tab’ that is a primary key?
CorrectIncorrect -
Question 7 of 15
7. Question
What is the output of the below code, the database db exists in the server?
import mysql.connector
db=mysql.connector.connect(user=”root”,passwd=”1234″,host=”localhost”,database=’db’)
my_cursor=db.cursor()
query=”CREATE TABLE tb(cl1 INT(10),cl2 VARCHAR(255), cl3 INT(10))”
my_cursor.execute(query)
my_cursor.execute(“INSERT INTO tb(cl1,cl2,cl3) VALUES(1,’a’,6)”)
db.commit()
print(my_cursor.rowcount)
CorrectIncorrect -
Question 8 of 15
8. Question
Which of the following commands is used to get all the tables in the database?
CorrectIncorrect -
Question 9 of 15
9. Question
What does the below command do, if the table name tb and it has 5 records?
query = “SELECT * FROM tb”
my_cursor.execute(query)
print(my_cursor.fetchone())
CorrectIncorrect -
Question 10 of 15
10. Question
Which of the following command inserts multiple records at once into the table tb containing 3 columns cl1,cl2,cl3?
CorrectIncorrect -
Question 11 of 15
11. Question
What is the following code select from table tb containing 3 columns cl1,cl2,cl3?
query = “SELECT cl1 FROM tb WHERE cl1>1”
my_cursor.execute(query)
CorrectIncorrect -
Question 12 of 15
12. Question
Which of the following is the correct way to delete all the information from the table tb?
CorrectIncorrect -
Question 13 of 15
13. Question
Which of the following is the correct command to change all the value of the cl3 to 1 from table tb containing 3 columns cl1,cl2,cl3?
CorrectIncorrect -
Question 14 of 15
14. Question
What is the function of the below code from table tb containing 3 columns cl1,cl2,cl3?
query = “DELETE FROM tb WHERE cl1 = 1”
my_cursor.execute(query)
CorrectIncorrect -
Question 15 of 15
15. Question
Which of the following commands is used to delete a table?
CorrectIncorrect