ComputerDatabase Connectivity With Python MCQs
Practice Database Connectivity With Python MCQs for competitive exams.
Database Connectivity With Python MCQs
Practice questions from this topic.
What is the purpose of database normalization?
- A. To reduce database size
- B. To increase database speed
- C. To organize data and eliminate redundancy
- D. To enforce strict typing
Correct Answer: C
How can you rollback a transaction in the sqlite3 module?
- A. Using the commit() method
- B. Using the rollback() method
- C. By closing the connection
- D. By re-executing the transaction
Correct Answer: B
Which of the following is NOT an isolation level for database transactions?
- A. READ UNCOMMITTED
- B. READ COMMITTED
- C. REPEATABLE READ
- D. DATA UNCHANGED
Correct Answer: D
What is the purpose of database transactions?
- A. To improve database performance
- B. To create new databases
- C. To manage data integrity and consistency
- D. To encrypt database files
Correct Answer: C
How do you execute a stored procedure from Python using the sqlite3 module?
- A. Using the execute() method
- B. Using the call() function
- C. Using the run() method
- D. Using the exec_procedure() function
Correct Answer: A
What is the purpose of a stored procedure in a database?
- A. To store data backups
- B. To define data types
- C. To encapsulate SQL code for reuse
- D. To generate random data
Correct Answer: C
How can you update data in a database table using SQL?
- A. Using the UPDATE statement
- B. Using the MODIFY statement
- C. Using the ALTER statement
- D. Using the EDIT statement
Correct Answer: A
What does the term "CRUD" stand for in the context of databases?
- A. Create, Read, Update, Delete
- B. Control, Remove, Update, Deliver
- C. Copy, Read, Upload, Delete
- D. Create, Retrieve, Upload, Deliver
Correct Answer: A
What is the role of a foreign key in a relational database?
- A. To prevent unauthorized access
- B. To ensure data integrity and relationships
- C. To index the database table
- D. To encrypt data
Correct Answer: B
What is a primary key in a database table?
- A. A key used to access the database
- B. A unique identifier for each row
- C. A password for the database
- D. A column used for calculations
Correct Answer: B
How do you define a class that maps to a database table using SQLAlchemy?
- A. By subclassing the Database class
- B. By using the @database_table decorator
- C. By inheriting from the Base class and defining attributes
- D. By using the map_table() function
Correct Answer: C
Which ORM library is popular for Python database connectivity?
- A. SQLLink
- B. ORMpy
- C. SQLAlchemy
- D. PyORM
Correct Answer: C