
🌟 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
KHỐI 12 -4 bài đầu
Quiz
•
12th Grade
20 questions
Colour Theory
Quiz
•
12th Grade - University
20 questions
VPS
Quiz
•
12th Grade
25 questions
Codehs - Python
Quiz
•
11th - 12th Grade
21 questions
SAINS KOMPUTER TINGKATAN 4 - PENGENALAN PANGKALAN DATA
Quiz
•
7th - 12th Grade
20 questions
HISTORY OF COMPUTER_SUMMATIVE 1
Quiz
•
11th - 12th Grade
21 questions
How the Internet Works & Web Design Intro
Quiz
•
7th - 12th Grade
17 questions
Quiz 01 Keamanan Jaringan
Quiz
•
12th Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
Discover more resources for Computers
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
15 questions
Christmas Song Emoji Pictionary
Quiz
•
7th - 12th Grade
20 questions
Christmas Movies
Quiz
•
1st - 12th Grade
55 questions
CHS Holiday Trivia
Quiz
•
12th Grade
20 questions
Christmas Movie Trivia
Quiz
•
9th - 12th Grade
29 questions
christmas facts
Lesson
•
5th - 12th Grade
20 questions
Christmas Trivia
Quiz
•
5th - 12th Grade
20 questions
Stages of Meiosis
Quiz
•
9th - 12th Grade