0% found this document useful (0 votes)
200 views

Student Marklist Application: Program

This document contains code for several GUI-based database applications including a student marklist application, payroll application, library management application and bank application. The code defines functions to connect to a MySQL database, insert, update and select data from tables. User interfaces are created using Tkinter with labels, text boxes and buttons to accept user input and perform database operations by calling the defined functions.

Uploaded by

Lavanya Kv
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
200 views

Student Marklist Application: Program

This document contains code for several GUI-based database applications including a student marklist application, payroll application, library management application and bank application. The code defines functions to connect to a MySQL database, insert, update and select data from tables. User interfaces are created using Tkinter with labels, text boxes and buttons to accept user input and perform database operations by calling the defined functions.

Uploaded by

Lavanya Kv
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

STUDENT MARKLIST APPLICATION

PROGRAM:

from Tkinter import *


import MySQLdb

def func():
conn = MySQLdb.connect (host = "localhost", user = "root",passwd = "jec",db = "test")
cursor = conn.cursor ()
Box6.delete(0, END)
name=Box1.get().strip()
roll=int(Box2.get().strip())
m1=int(Box3.get().strip())
m2=int(Box4.get().strip())
m3=int(Box5.get().strip())
if m1=="" or m2 =="" or m3=="" : return
avg = (m1 + m2 + m3) / 3
Box6.insert(0,avg)
cursor.execute("insert into stud values('"+name+"',"+str(roll)
+","+str(m1)+","+str(m2)+","+str(m3)+","+str(avg)+")")
cursor.close ()
conn.close ()
master = Tk()
master.title("student record")

Label1 = Label(master,text="name")
Label1.pack()
Box1=Entry(master)
Box1.pack()

Label2 = Label(master,text="roll")
Label2.pack()
Box2=Entry(master)
Box2.pack()

Label3 = Label(master,text="m1")
Label3.pack()
Box3=Entry(master)
Box3.pack()

Label4 = Label(master,text="m2")
Label4.pack()
Box4=Entry(master)
Box4.pack()
Label5 = Label(master,text="m3")
Label5.pack()
Box5=Entry(master)Box5.pack()
Label6 = Label(master,text="avg")
Label6.pack()
Box6=Entry(master)
Box6.pack()
button = Button(master, text="Submit", command=func).pack()
mainloop()

OUTPUT:

jec@jec-desktop:~$ mysql -u root -p


Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from stud;
+------+------+------+------+------+------+
| name | roll | m1 | m2 | m3 | avg |
+------+------+------+------+------+------+
| 11 | 11 | 11 | 11 | 11 | 11 |
| sam | 78 | 89 | 89 | 89 | 89 |
| sam | 78 | 89 | 89 | 89 | 89 |
+------+------+------+------+------+------+
3 rows in set (0.00 se

PAYROLL
APPLICATION

PROGRAM:
from Tkinter import *
import MySQLdb
def func():
conn = MySQLdb.connect (host = "localhost", user = "root",passwd = "jec",db = "test")
cursor = conn.cursor ()
Box4.delete(0, END)
Box5.delete(0,END)
Box7.delete(0,END)
Box8.delete(0,END)
name=Box1.get().strip()
no=int(Box2.get().strip())
basicpay=int(Box3.get().strip())
cca=int(Box6.get().strip())
if name=="" or no =="" or basicpay=="" or cca=="" : return
da=90*basicpay/100
hra=20*basicpay/100
itax=10*basicpay/100
netpay=(basicpay+da+hra+cca)-itax
Box4.insert(0,da)
Box5.insert(0,hra)
Box7.insert(0,itax)
Box8.insert(0,netpay)
cursor.execute("insert into payroll values('"+name+"',"+str(no)+","+str(basicpay)+","+str(da)
+","+str(hra)+","+str(cca)+","+str(itax)+","+str(netpay)+")")
cursor.close ()
conn.close ()
master = Tk()
Label1 = Label(master,text="name")
Label1.pack()
Box1=Entry(master)
Box1.pack()

Label2 = Label(master,text="no")
Label2.pack()
Box2=Entry(master)
Box2.pack()

Label3 = Label(master,text="basicpay")
Label3.pack()
Box3=Entry(master)
Box3.pack()

Label4 = Label(master,text="da")
Label4.pack()
Box4=Entry(master)
Box4.pack()

Label5 = Label(master,text="hra")
Label5.pack()
Box5=Entry(master)
Box5.pack()

Label6 = Label(master,text="cca")
Label6.pack()
Box6=Entry(master)
Box6.pack()

Label7 = Label(master,text="itax")
Label7.pack()
Box7=Entry(master)
Box7.pack()

Label8 = Label(master,text="netpay")
Label8.pack()
Box8=Entry(master)
Box8.pack()

button = Button(master, text="Submit", command=func).pack()


mainloop()

OUTPUT:
jec@jec-desktop:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test

Database changed
mysql> create table payroll(name varchar(20),no int,basicpay int,da float,hra float,cca int,itax
float,netpay float)
-> ;
Query OK, 0 rows affected (0.01 sec)
mysql> select * from payroll;
+------+------+----------+------+------+------+------+--------+
| name | no | basicpay | da | hra | cca | itax | netpay |
+------+------+----------+------+------+------+------+--------+
| Shah | 10 | 1000 | 900 | 200 | 2000 | 100 | 4000 |
+------+------+----------+------+------+------+------+--------+
1 row in set (0.00 sec)
LIBRARY MANAGEMENT APPLICATION

PROGRAM:
from Tkinter import *
import MySQLdb
def func():
first= Tk()
Label1 = Label(first,text="bkno")
Label1.pack()
Box1=Entry(first)
Box1.pack()
Label2 = Label(first,text="bkname")
Label2.pack()
Box2=Entry(first)
Box2.pack()
Label3 = Label(first,text="author")
Label3.pack()
Box3=Entry(first)
Box3.pack()
Label4 = Label(first,text="publisher")

Label4.pack()
Box4=Entry(first)
Box4.pack()
def func1():
conn = MySQLdb.connect (host = "localhost", user = "root",passwd = "jec",db = "test")
cursor = conn.cursor ()
bkno=int(Box1.get().strip())
bkname=Box2.get().strip()
author=Box3.get().strip()
publisher=Box4.get().strip()
if bkno=="" or bkname =="" or author=="": return
cursor.execute("insert into library values("+str(bkno)+",'"+(bkname)+"','"+(author)+"','"+
(publisher)+"')")
cursor.close ()
conn.close ()
Button3 = Button(first, text="INSERT", command=func1).pack()
def select():
second = Tk()
Label1 = Label(second,text="bkno")
Label1.pack()
Box1=Entry(second)
Box1.pack()
Label2 = Label(second,text="bkname")
Label2.pack()
Box2=Entry(second)
Box2.pack()
Label3 = Label(second,text="author")
Label3.pack()
Box3=Entry(second)
Box3.pack()
Label4 = Label(second,text="publisher")
Label4.pack()
Box4=Entry(second)
Box4.pack()
def func2():
conn = MySQLdb.connect (host = "localhost", user = "root",passwd = "jec",db = "test")
cursor = conn.cursor ()
bkno=int(Box1.get().strip())
bkname=Box2.get().strip()
author=Box3.get().strip()
publisher=Box4.get().strip()
Box1.delete(0, END)
Box2.delete(0, END)
Box3.delete(0, END)
Box4.delete(0, END)
try:
sql="select * from library where bkno> '%d'" % bkno
cursor.execute(sql)
row1=cursor.fetchone ()

Box1.insert(0,row1[0])
Box1.pack()
Box2.insert(0,row1[1])
Box2.pack()
Box3.insert(0,row1[2])
Box3.pack()
Box4.insert(0,row1[3])
Box4.pack()
cursor.close()
conn.close()
except:
print "Error:End of the table"
Button3 = Button(second, text="NEXT", command=func2).pack()
master = Tk()
Button1 = Button(master, text="INSERT", command=func).pack()
Button2 = Button(master, text="SELECT", command=select).pack()
mainloop()

OUTPUT:
jec@jec-desktop:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test
Database changed
mysql> select * from library;
+------+--------+--------------+-----------+
| bkno | bkname | author | publisher |
+------+--------+--------------+-----------+
| 100 | DBMS | Silberschatz | Pearlin |
+-----+--------+--------------+-----------+
1 row in set (0.00 sec)

BANK APPLICATION

PROGRAM:
from Tkinter import *
import MySQLdb
def func():
first= Tk()
Label1 = Label(first,text="accno")
Label1.pack()
Box1=Entry(first)
Box1.pack()
Label2 = Label(first,text="name")
Label2.pack()
Box2=Entry(first)
Box2.pack()
Label3 = Label(first,text="balance")
Label3.pack()

Box3=Entry(first)
Box3.pack()
def func1():
conn = MySQLdb.connect (host = "localhost", user = "root",passwd = "jec",db = "test")
cursor = conn.cursor ()
accno=int(Box1.get().strip())
name=Box2.get().strip()
balance=int(Box3.get().strip())
if accno=="" or name =="" or balance=="": return
cursor.execute("insert into account values('"+name+"',"+str(accno)+","+str(balance)+")")
cursor.close ()
conn.close ()
Button3 = Button(first, text="add", command=func1).pack()
def debit():
second = Tk()
Label1 = Label(second,text="acc")
Label1.pack()
Box1=Entry(second)
Box1.pack()
Label3 = Label(second,text="balance")
Label3.pack()
Box3=Entry(second)
Box3.pack()
Label4 = Label(second,text="amount")
Label4.pack()
Box4=Entry(second)
Box4.pack()
def func2():
conn = MySQLdb.connect (host = "localhost", user = "root",passwd = "jec",db = "test")
cursor = conn.cursor ()
acc=int(Box1.get().strip())
balance=int(Box3.get().strip())
amount=int(Box4.get().strip())
cursor.execute("update account set balance="+str(balance)+"-"+str(amount)+" where
accno="+str(acc)+"")
if acc=="" or balance=="": return
cursor.close ()
conn.close ()
Button3 = Button(second, text="SUBMIT", command=func2).pack()
def trans():
third= Tk()
Label1 = Label(third,text="From account")
Label1.pack()
Box1=Entry(third)
Box1.pack()

Label2 = Label(third,text="To account")


Label2.pack()
Box2=Entry(third)
Box2.pack()
Label3 = Label(third,text="Amount")
Label3.pack()
Box3=Entry(third)
Box3.pack()
def func3():
conn = MySQLdb.connect ("localhost","root","jec","test")
cursor = conn.cursor ()
From=int(Box1.get().strip())
To=int(Box2.get().strip())
Amount=int(Box3.get().strip())
cursor.execute("select balance from account where accno="+str(From)+"")
a=cursor.fetchone ()
fromval=int(a[0])
cursor.execute("select balance from account where accno="+str(To)+"")
b=cursor.fetchone ()
toval=int(b[0])
fromval=fromval-Amount
toval=toval+Amount
cursor.execute("update account set balance="+str(fromval)+" where accno="+str(From)+"")
cursor.execute("update account set balance="+str(toval)+" where accno="+str(To)+"")
cursor.close ()
conn.close ()
Button3 = Button(third, text="NEXT", command=func3).pack()
master = Tk()
Button1 = Button(master, text="CREDIT", command=func).pack()
Button2 = Button(master, text="DEBIT", command=debit).pack()
Button3 = Button(master, text="TRANSACTION", command=trans).pack()
mainloop()

OUTPUT:
jec@jec-desktop:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test

Database changed
mysql> select * from bank;
mysql> select * from account;
+------+-------+---------+
| name | accno| balance|
+------+-------+---------+
| Shah | 100 | 400 |
| Rukh | 200 | 1000 |
+------+-------+---------+
2 rows in set (0.02 sec)

You might also like