12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 06/01/2020
Data Manipulation Through SQL
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
Which of the following statement in SQL is used to retrieve or fetch data from a table in a database?
select
inset
create
fetch
2.
Which method has a major role in working with python?
cursor ( )
connect ( )
execute ( )
close
3.
The most commonly used statement in SQL is
cursor
select
execute
commit
4.
Which of the following function retrieves the average of a selected column of rows in a table?
Add()
SUM()
AVG( )
AVERAGE()
5.
Which of the following executes the SQL command to perform some action?
Execute()
Key()
Cursor()
run()
6.
How the SQL DISTINCT class is helpful to you?
7.
How the cursor object is created?
8.
Which method is used to fetch all rows from the database table?
9.
Write the command to populate record in a table. Give an example.
10.
Which method is used to connect a database? Give an example.
11.
Explain how a connect to be made to a database (Academy through python SQlite3.
12.
Write the sqlite steps to connect the database.
13.
Read the following details.Based on that write a python script to display records in desending order of
Eno
database name :- organization.db
Table name :- Employee
Columns in the table :- Eno, EmpName, Esal, Dept
14.
What is the use of Where Clause.Give a python statement Using the where clause.
15.
16.
Consider the following table Supplier and item .Write a python script for (i) to (ii)
| SUPPLIER | ||||
| Suppno | Name | City | Icode | SuppQty |
| S001 | Prasad | Delhi | 1008 | 100 |
| S002 | Anu | Bangalore | 1010 | 200 |
| S003 | Shahid | Bangalore | 1008 | 175 |
| S004 | Akila | Hydrabad | 1005 | 195 |
| S005 | Girish | Hydrabad | 1003 | 25 |
| S006 | Shylaja | Chennai | 1008 | 180 |
| S007 | Lavanya | Mumbai | 1005 | 325 |
i) Display Name, City and Itemname of suppliers who do not reside in Delhi.
ii) Increment the SuppQty of Akila by 40
17.
hat is the use of HAVING clause. Give an example python script
18.
Write the Python script to display all the records of the following table using fetchmany()
| Icode | ItemName | Rate |
| 1003 | Scanner | 10500 |
| 1004 | Speaker | 3000 |
| 1005 | Printer | 8000 |
| 1008 | Monitor | 15000 |
| 1010 | Mouse | 700 |
19.
Write in brief about SQLite and the steps used to use it.
1.
(a)
select
2.
(a)
cursor ( )
3.
(b)
select
4.
(c)
AVG( )
5.
(a)
Execute()
6.
The DISTINCT clause is helpful when there is need of avoiding the duplicate values present in any specific columns/table. When we use distinct keyword only the unique values are fetched.
7.
The cursor object is created by calling the cursor ( ) method of connection. The cursor is used to traverse the records from the result set.
8.
The fetchall() method is used to fetch all rows from the database table.
result = cursor. fetchall()
9.
To populate the table "INSERT" command is passed to SQLite."execute" method executes the SQL command to perform some action.
Example:
Sql_command =" " INSERT INTO student (Rollno, Sname, Grade, Gender, Average, birth_date) values (NULL, "Akshay", "B", "M", "87.8", "2001-12-12");" " cursor.execute(sql_command)
10.
Create a connection using connect() method and pass the nanie of the database file.
Example:
#connecting to the database
connection = sqlite3.connect ("Academy.db")
#cursor
cursor = connection.cursor()
11.
# Python code to demonstrate table creation and insertions with SQL
# importing module
import sqlite3
# connecting to the database
connection = sqlite3.connect ("Academy.db")
# cursor
cursor = connection.cursor ( )
12.
Step 1: Import sqlite3
Step 2: Create a connection using connect o method and pass the name of the database File
Step 3: Set the cursor object cursor = connection. cursor ( )
13.
Program: Display the records in descending order using python script
import mysqldb
db = mysqldb.connect ("local host", "user", "123", "organization")
cursor = db.cursor()
cursor.execute ("SELECT *FROM Employee ORDER BY Name DESC")
result = cursor.fetchall()
for row in results:
ENO = row[0], EmpName = row[1], EmpDept = row[2]
print ENO, EmpName, EmpDept
db.close()
14.
The WHERE clause is used to extract only those records that fulfill a specified condition. In this example we are going to display the different grades scored by male students from "student table.
import sqlite3
connection = sqlite3.connect ("Academy.db")
cursor = connection.cursor()
cursor.execute ("SELECT DISTINCT (Grade) FROM student where gender = "M")
result = cursor.fetchall()
print(* result, sep ="\n")
Output:
('B,')
('A,')
('C,')
('D,')
15.
16.
(i) Program to Display Name, city and Item Name of suppliers who do not reside in Delhi:
import mysqldb
db = mysqlkdb.Connect ("Supplier.db")
cursor = db.cursor()
cursor. execute ("'SELECT NAME, CITY, ICode FROM Supplier WHERE CITY <> "Delh")
db. commit()
result=cursor.fetchall()
print ("result, sep = "\n")
db. close()
(ii) Program to Increment the suppQty of Akila by 40:
import mysqldb
db = mysqldb.Connect ("ltem.db"')
cursor = db.cursor()
cursor. execute ("UPDATE Item SET Name = 'Akila' WHERE SuppQty = 235)
db. commit()
cursor. execute ("SELECT * FROM Item")
result = cursor.fetchall()
print ("result, sep ="\n")
db. close()
17.
HAVING clause is used to filter data based on7the group functions. This is similar to WHERE condition but can be used , only with group functions. Group functions cannot be used in WHERE Clause but can be used in HAVING clause.
Example:
import sqlite3
connection = sqlite3.connect("Academy.db")
cursor = connection.cursorO
cursor.execute("SELECT GENDER,COUNT(GENDER) FROM Student GROUP BY GENDER HAVING COUNT( GENDER> 3")
result = cursor.fetchall( )
co = [i[o] for i in cursor. description]
print(co)
print(result)
Output:
['gender', 'COUNT(GENDER)']
[('M', 5)]
18.
Creating database:
Sql_command = " "
CREATE TABLE Hardware (
lcode INTEGER PRIMARY KEY.
ltem_Name VARCHAR(20),
Rate DEClMAL(5,2));" "
Program: To display the records using fetchmany()
import sqlite3
connection = sqlite3.connect ("Material.db")
cursor = connection.cursor()
cursor. execute ("SELECT * FROM Hardware")
print("fetching first 5 records:")
result = cursor.fetchmany(5)
print(result)
Output:
fetching first 5 records:
[(1003, 'Scanner', "10500'), (1004, 'Speaker', '3000'), (1005, 'Printer', '8000'), (1008, 'Monitor', '15000'),
(1010, 'Mouse', '700')]
19.
(i) SQLite is a simple relational database system, which saves its data in regular data files or even in the internal memory of the computer.
(ii) It is designed to be embedded in applications, instead of using a separate
database server program such as MySQL or Oracle.
(iii) SQLite is fast, rigorously tested, and flexible, making it easier to work. Python
has a native library for SQLite.
To use SQLite,
Step 1: import sqlite3
Step 2: create a connection using connect() method and pass the name of the database file
Step 3: Set the cursor object cursor = connection. cursor()
(iv) Connecting to a database in step 2 means passing the name of the database to be accessed. If the database already exists the connection will open the same. Otherwise, Python will open a new database file with the specified name.
(v) Cursor in step 3 is a control structure used to traverse and fetch the records of the database.
(vi) Cursor has a major role in working with Python. All the commands will be executed using cursor object only.
(vii) To create a table in the database, create an object and write the SQL command in it.
Example: sql_comm = "SQL statement"
(viii) For executing the command use the cursor method and pass the required sql command as a parameter. Many number of commands can be stored in the sql comm and can be executed one after other.
(ix) Any changes made in the values of the record should be saved by the commend "Commit" before closing the "Table connection" .
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards