From 2d3a9ff598905031dcfef104756b14b5585ac4e3 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Sun, 10 Nov 2024 15:52:25 +0530 Subject: [PATCH] added comments for update and delete opn and added new line char in python3 execution command to automatically execute on copying. lastly changed pip to python3-pip --- .../Practical Exam/Connectivity/C2 - MySQL Connectivity.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Practical/Practical Exam/Connectivity/C2 - MySQL Connectivity.md b/Practical/Practical Exam/Connectivity/C2 - MySQL Connectivity.md index 53869be..89475c9 100644 --- a/Practical/Practical Exam/Connectivity/C2 - MySQL Connectivity.md +++ b/Practical/Practical Exam/Connectivity/C2 - MySQL Connectivity.md @@ -7,7 +7,7 @@ ## Pre-requisites (with installation command for Ubuntu): 1. Python3 - `sudo apt install python3` -2. pip - `sudo apt install pip` +2. pip - `sudo apt install python3-pip` 3. mysql-connector - `pip3 install mysql-connector` OR `pip3 install mysql-connector --break-system-packages` (installs it system-wide) ## Instructions @@ -67,11 +67,11 @@ Cursor.execute(sqlInsert) sqlInsert = "INSERT INTO students (roll, name) VALUES (22, 'Foxy')" # insert operation print(Cursor.rowcount, "record added to database.") -sqlUpdate = "UPDATE students SET roll = 21 WHERE roll = 20" +sqlUpdate = "UPDATE students SET roll = 21 WHERE roll = 20" # update operation Cursor.execute(sqlUpdate) print(Cursor.rowcount, "record updated.") -sqlDelete = "DELETE FROM students WHERE roll = 20" +sqlDelete = "DELETE FROM students WHERE roll = 20" # delete operation Cursor.execute(sqlDelete) print(Cursor.rowcount, "record deleted.") @@ -84,6 +84,7 @@ db.close() 6. Open Terminal and run the above program: ```shell python3 connectSQL.py + ``` > [!NOTE]