Professional Documents
Culture Documents
Practical File
R.Srikrishna kashyap
Class - XII-A
Roll No -31
CERTIFICATE
Principal
Database Management System
1. Creating a Database
Command: create database bank;
# Account
Create table accounts
( Account_no int Primary keys
Branch_name Varchar (30)
Balance int ) ;
# Customer
Create table Customer
( Customer_name Varchar (30) ,
Customer_city Varchar (30)
Customer_Street Varchar(30));
# Depositer
Create table Depositer
( Customer name Varchar(30),
Account no int):
#Loan
Create table loan
( loan_no int primary key,
Branch_name varchar(30),
Loan_amount int);
#Borrower
Create table borrower
(laon_no int primary key,
Customer_name varchar(45));
#Customer
Insert into customer values
(‘Devaram’ , ‘Malwani No.1’, ‘Mumbai’),
(‘Asha Waghmare’ , ‘jankalyan nagar’ , ‘Mumbai’),
(‘Arjun Ram’, ‘Karol Baug’ , ‘New Delhi’),
(‘Shabbana Bano’ , ‘Chandani Chowk’ , ‘New Delhi’),
(‘john’, ‘Mansarovar’, ‘Jaipur’),
(‘Devendra singh’ , ‘Shashtri Nagar’ , ‘Jaipur’),
(‘Laxmi Devi’, ‘Khatipura’ , ‘Jaipur’),
(‘Birbal Ram’ , ‘Dariyaganj’ , ‘New Delhi’),
(‘Dinesh Kumar’ , ‘Malviya Nagar’ , ‘Jaipur’);
# Depositor
Insert into depositor values
(‘Devaram’, 5000),
(‘Asha WAaghnmare’, 5001),
(‘Asha Waghmare’, 5002),
(‘Arjun Ram’, 6001),
(‘Shababana Bano’, 6002),
(‘Devemdra Singh’, 7001),
(‘Laxmi Devi’, 7002);
#Loan
Insert into loan values
(1551 , ‘Malad West’ , 200000)
(1552 , ‘Connaught Place’ , 245000)
(1553 , ‘Vaishali Nagar’ , 567000)
(1554 , ‘Vaishali Nagar’ , 435000)
(1555 , ‘Malad West’, 225000)
(1556 , ‘Vaishali Nagar’, 155000);
#Borrower
Insert into borrower values
( 1551 , ‘Asha Waghmare’ )
( 1552 , ‘shabbana Bano’)
( 1553 , ‘John’ )
( 1554 , ‘Dinesh Kumar’)
( 1555 , ‘Birbal Ram’ )
( 1556 , ‘Laxmi Devi’ );
4. Find the names and street addresses of
customers who belong to New Delhi.
Command: select customer_name,customer_street
from customer where customer_city = ‘new
delhi’;
import mysql.connector as mc
con = mc.connect(host = 'localhost', username ='root',
password = 'Rskk@2020',database = 'bank')
cur = con.cursor()
print("1.Account\n2.Branch\n3.Borrower\n4.Customer\n5.D
epositer\n6.Loan")
in1 = int(input("Enter The Number Of The Table: "))
if in1 == 1:
accn = int(input("Enter Account Number: "))
branch = input("Enter Branch Name: ")
balance = int(input("Enter The Balance: "))
cur.execute("insert into account
values({},'{}',{})".format(accn,branch,balance))
con.commit()
print("Data Entered Successfully....")
if in1 == 2:
branch = input("Enter Branch Name: ")
city = input("Enter The City: ")
assets = int(input("Enter Assets: "))
cur.execute("insert into branch values
('{}','{}',{})".format(branch,city,assets))
con.commit()
print("Data Entered Successfully....")
if in1 == 3:
loanno = int(input("Enter Loan Number: "))
Customer_name = input("Enter The Name Of The
Customer: ")
cur.execute("insert into borrower
values({},'{}')".format(loanno,Customer_name))
con.commit()
print("Data Entered Successfully....")
if in1 == 4:
Customer_name = input("Enter The Name Of The
Customer: ")
Customer_city = input("Enter The City Of The
Customer: ")
Customer_street = input("Enter The Street Of The
Customer: ")
cur.execute("insert into customer values
('{}','{}','{}')".format(Customer_name,Customer_city,Cu
stomer_street))
con.commit()
print("Data Entered Successfully....")
if in1 == 5:
Customer_name = input("Enter The Name Of The
Customer: ")
accn = int(input("Enter Account Number: "))
cur.execute("insert into depositer values
('{]',{})".format(Customer_name,accn))
con.commit()
print("Data Entered Successfully....")
if in1 == 6:
loanno = int(input("Enter Loan Number: "))
branch = input("Enter Branch Name: ")
loan_amount = int(input("Enter Loan Amount: "))
cur.execute ("insert into loan values
({},'{}',{})".format(loanno,branch,loan_amount))
con.commit()
print("Data Entered Successfully....")
2. Write a program to show the data present in
the table in bank database where table name is
entered by the user.
import mysql.connector as mc
con = mc.connect(host = 'localhost', username ='root',
password = 'Rskk@2020',database = 'bank')
cur = con.cursor()