Home | | Computer Science 12th Std | Deletion Operation

Data Manipulation Through SQL - Deletion Operation | 12th Computer Science : Chapter 15 : Integrating Python with MySql and C++ : Data Manipulation Through SQL

Chapter: 12th Computer Science : Chapter 15 : Integrating Python with MySql and C++ : Data Manipulation Through SQL

Deletion Operation

Similar to Sql command to delete a record, Python also allows to delete a record.

Deletion Operation

Similar to Sql command to delete a record, Python also allows to delete a record. The following example delete the content of Rollno 2 from "student table"

Example

#code for delete operation

import sqlite3

#database name to be passed as parameter

conn = sqlite3.connect("Academy.db")

#delete student record from database

conn.execute("DELETE from Student where Rollno='2'")

conn.commit()

print("Total number of rows deleted :", conn.total_changes)

cursor =conn.execute("SELECT * FROM Student")

for row in cursor: print(row)

conn.close()

OUTPUT

Total number of rows deleted : 1

(1, 'Akshay', 'B', 'M', 87.8, '2001-12-12')

(3, 'BASKAR', 'C', 'M', 75.2, '1998-05-17')

(4, 'SAJINI', 'A', 'F', 95.6, '2002-11-01')

(5, 'VARUN', 'B', 'M', 80.6, '2001-03-14')

(6, 'Priyanka', 'A', 'F', 98.6, '2002-01-01')

(7, 'TARUN', 'D', 'M', 62.3, '1999-02-01')

 

Tags : Data Manipulation Through SQL , 12th Computer Science : Chapter 15 : Integrating Python with MySql and C++ : Data Manipulation Through SQL
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
12th Computer Science : Chapter 15 : Integrating Python with MySql and C++ : Data Manipulation Through SQL : Deletion Operation | Data Manipulation Through SQL


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.