
🌟 Python + MySQL Connectivity
Authored by Harmeet Kaur
Computers
12th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
22 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct method to prevent SQL injection when inserting user input into a MySQL database using PyMySQL?
Use string concatenation for query formation
Use %s placeholders in the query and pass values as a tuple
Use f-string formatting in SQL queries
Use raw input directly in the SQL query
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a Python program using PyMySQL, what happens if you attempt to insert a record into a table where a NOT NULL column is left empty and no default value is set?
The record is inserted with NULL in that column
A ProgrammingError is raised by PyMySQL
A DataError is raised by the MySQL server
An IntegrityError is raised by PyMySQL
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider a table orders(order_id INT PRIMARY KEY, customer_id INT, order_date DATE) and customers(customer_id INT PRIMARY KEY, name VARCHAR(50)). Which query retrieves all orders along with customer names, ensuring that orders without a matching customer are also shown?
SELECT * FROM orders JOIN customers USING(customer_id)
SELECT * FROM orders INNER JOIN customers ON orders.customer_id = customers.customer_id
SELECT * FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id
SELECT * FROM orders RIGHT JOIN customers ON orders.customer_id = customers.customer_id
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given a PyMySQL connection object conn, how do you ensure that changes made via cursor operations are permanently saved in the database?
Use conn.save()
Call conn.commit()
Call conn.flush()
Call cursor.commit()
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is NOT a valid reason for a MySQLdb._exceptions.OperationalError: (2006, "MySQL server has gone away") error?
Query execution timeout
Server closed the connection due to inactivity
Data size in a single packet exceeds max_allowed_packet
Primary key constraint violation in INSERT query
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a PyMySQL program, you attempt to execute the following query: cursor.execute("SELECT * FROM flights WHERE destination = %s", "London"). What is the issue in this statement?
The placeholder %s must be replaced with the actual value before execution
The value “London” must be passed as a tuple
The query will work without any issue
The query requires a dictionary instead of a tuple for parameter passing
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following tasks would typically require the use of the tabulate module in a PyMySQL application?
Validating data types in a MySQL table
Displaying query results in a formatted table view in the console
Handling SQL exceptions in Python
Automating database backups
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
Kelompok 4
Quiz
•
12th Grade
20 questions
مراجعة البيانات الضخمة وذكاء الاعمال
Quiz
•
12th Grade
20 questions
Module 5 Test Review - Cengage Mindtap
Quiz
•
9th - 12th Grade
20 questions
Web Browser
Quiz
•
11th - 12th Grade
20 questions
Quiz sulla Sicurezza Informatica
Quiz
•
12th Grade - University
18 questions
Big Data
Quiz
•
9th - 12th Grade
18 questions
Database Management System
Quiz
•
12th Grade - Professi...
19 questions
Unit 6 - lesson 2 Network Topology
Quiz
•
10th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade