1. What is database connectivity in Python? A. Connecting to internet databases B. Establishing a connection between Python and databases C. Creating new databases using Python D. Sending emails from Python to databases Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B Solution: Database connectivity refers to establishing a connection between Python and databases to perform operations.
2. Which module is commonly used for database connectivity in Python? A. dbconnect B. pydb C. sqlite3 D. dbconnector Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: The sqlite3 module is widely used for database connectivity in Python, especially for SQLite databases.
3. What is SQLite? A. A type of programming language B. A relational database management system C. A Python module for web scraping D. A version control system Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B Solution: SQLite is a lightweight, self-contained, serverless, and file-based relational database management system.
4. How can you create a new SQLite database using the sqlite3 module? A. Using the create_database() function B. By writing SQL queries C. By calling the new_database() method D. By executing the sqlite3.create() command Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B Solution: New SQLite databases are created by executing SQL queries to define tables and data structures.
5. What is a cursor in the context of database connectivity? A. A pointer to a specific table B. A tool for creating graphs C. An object used to interact with the database D. A graphical user interface element Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: A cursor is an object that allows you to interact with a database by executing SQL commands and fetching results.
6. How do you establish a connection to an SQLite database using sqlite3? A. connect("database.db") B. create_connection("database.db") C. sqlite_connect("database.db") D. open_connection("database.db") Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A Solution: The connect() function is used to establish a connection to an SQLite database.
7. What is the purpose of the execute() method in the sqlite3 module? A. To print messages to the console B. To fetch data from a database C. To execute SQL queries on a database D. To create new tables in a database Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: The execute() method is used to execute SQL queries on an SQLite database.
8. What is SQL injection? A. A type of data visualization technique B. A way to add colors to SQL databases C. A technique to manipulate SQL databases D. A security vulnerability when input is not properly sanitized Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D Solution: SQL injection is a security vulnerability where malicious code is inserted into SQL statements.
9. How do parameterized queries help prevent SQL injection? A. By encrypting database queries B. By removing SQL keywords C. By sanitizing user input D. By executing multiple queries at once Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: Parameterized queries separate user input from SQL code, reducing the risk of SQL injection.
10. Which of the following is NOT a common SQL database management system? A. MySQL B. PostgreSQL C. MongoDB D. SQLite Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: MongoDB is a NoSQL database management system, while the others are relational databases.