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

This commit is contained in:
K 2024-11-10 15:52:25 +05:30
parent 3692f8819d
commit 2d3a9ff598
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -7,7 +7,7 @@
## Pre-requisites (with installation command for Ubuntu): ## Pre-requisites (with installation command for Ubuntu):
1. Python3 - `sudo apt install python3` 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) 3. mysql-connector - `pip3 install mysql-connector` OR `pip3 install mysql-connector --break-system-packages` (installs it system-wide)
## Instructions ## Instructions
@ -67,11 +67,11 @@ Cursor.execute(sqlInsert)
sqlInsert = "INSERT INTO students (roll, name) VALUES (22, 'Foxy')" # insert operation sqlInsert = "INSERT INTO students (roll, name) VALUES (22, 'Foxy')" # insert operation
print(Cursor.rowcount, "record added to database.") 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) Cursor.execute(sqlUpdate)
print(Cursor.rowcount, "record updated.") print(Cursor.rowcount, "record updated.")
sqlDelete = "DELETE FROM students WHERE roll = 20" sqlDelete = "DELETE FROM students WHERE roll = 20" # delete operation
Cursor.execute(sqlDelete) Cursor.execute(sqlDelete)
print(Cursor.rowcount, "record deleted.") print(Cursor.rowcount, "record deleted.")
@ -84,6 +84,7 @@ db.close()
6. Open Terminal and run the above program: 6. Open Terminal and run the above program:
```shell ```shell
python3 connectSQL.py python3 connectSQL.py
``` ```
> [!NOTE] > [!NOTE]