Resource 20200613110203 Assignment 9-Class Xii-Computer Science (Sql-Python-Interface) PDF
Resource 20200613110203 Assignment 9-Class Xii-Computer Science (Sql-Python-Interface) PDF
CITY CAMPUS,
DALANWALA, DEHRADUN
CLASS XII
COMPUTER SCIENCE
CHAPTER 10:
INTERFACE PYTHON WITH SQL
NOTES
+
SOLVED QUESTIONS
+
Exercise
PREPARED BY :
Ms. Anjali Sharma (PGT COMPUTER SCIENCE)
DOON INTERNATIONAL SCHOOL
CITY CAMPUS,
DALANWALA, DEHRADUN
Front End
The softwares through which we fetch input from the user are called Front End Interface.
These can be created using any programming language. Since languages like Python, VB and
Java support easy programming for creating GUI controls are a good choice for creating
Front End Interface.
Back End
The softwares that can store data permanently are called Back End. Since database software
allows users to store and manipulate data easily become a good choice for Back End.
Databases use SQL commands like CREATE, SELECT, INSERT, UPDATE, DELETE to manipulate
data.
Python-SQL connectivity
Python language has in build modules that are used to connect to the databases and also
store and retrieve data and all this can be done using only a few commands and functions.
This is called python-SQL connectivity.
3. execute()- this function will help us execute the SQL queries from python and
return results back to python. It is used for traverse through the record of the
database.
4. close()- this function will close the database connection.
5. is_connected()- the function return a Boolean value (True/False) to show if the
python program is connected to the database or not.
commit()-once a program is completed all the changes that were made to the
database are made permanent , once the commit() is used.
rollback()- if the transaction fails and we want to undo any changes made to the
database, we use the rollback() function.
Table: Student
Program 1
Program 2
x=cur.rowcount()
print(“ Total Number Of Records Added are……….”,x)
#add the record permanently
db1.commit()
Program 3
ASSIGNMENT
1. Write a Python program to increase the marks of all the students of class 11 B by 10.
2. Write a Python program to display records of all the students who are scoring above
90%
3. Write a Python program to remove the records of class 12G
4. Write a Python program to add record of a student with following details
Roll number=51, student name = John, class – 11F, marks=78