Uploaded by sadaf khan


Submitted in partial fulfillment of the requirements
of the Python Lab of
Second Year Bachelor of Engineering
in Information Technology
Kavita Gomase
Sadaf Khan
Under the Guidance of
Prof. Anuja Gote
Department of Information Technology Engineering
Vidyalankar Institute of Technology
Wadala(E), Mumbai-400437
University of Mumbai
The proposed “Book store management” will be used for maintaining the records of
the books in a store. To add a books in the database. For this Implementation we used Python
3.7 as a Front-end language and as for Back-end we used Sqlite3 software as a database for
this application to be implemented. This can help to manage the books in a store in wellmannered way. As well it can enhance in future by adding other features such as updating or
deleting a records in this way it can also managed to be used in a better way.
Page No
1. Introduction
The Project about “Department Store Management” for Books is implemented with
the help of Python by using Pycharm as a front-end language and a Sqlite3 as for database at
the Back-end for this application. This is a GUI based application developed in Python
tkinter. Tkinter is Python's de-facto standard GUI (Graphical User Interface) package. It is a
thin object-oriented layer on top of Tcl/Tk. In Pycharm we use Tkinter for providing
Graphical User Interface (GUI).
This application can provide a help to the owner of the shops to get rid of old file
system method and hectic work which causes lots of time waste. It can have error or cannot
give output instantly.
Disadvantage of File System:
 Redundancy of record
 Time consuming
 Error can be present
 Searching a record is difficult
 Hectic to handle
 Loss of data or a record
To cover up all these disadvantage of file system the database can be used as an application
to get rid of all these problem.
Advantage of Database over file system:
 Data is consistent
 Time Saving
 Searching of record is easy
 Easy to handle
 Error can be detected
 Speed in work
Thus we have replace a file system with a database which can have lots of advantages
and are easy to handle. This application can help many departments to have a computerized
application to handle their regular task in an easy manner. They can easily manage their
departments record this application can be used for any department here we have make this
application for a Books department.
They can manage the records of books and can view it any time and make make fast
decision which will also benefit for their department.
2. Software Requirement
Front End :
Python is a widely used general-purpose, high level programming language. It was
initially designed by Guido van Rossum in 1991 and developed by Python Software
Foundation. It was mainly developed for emphasis on code readability, and its syntax allows
programmers to express concepts in fewer lines of code.
Python is a programming language that lets you work quickly and integrate systems more
efficiently. It is an open source Language
We have use Python 3.7 version for our application since it is in latest version series
with additional features in it. The Python 3.7 series is the newest major release of the Python
language and contains many new features and optimizations.
Among the major new features in Python 3.7 are:
Avoiding the use of ASCII as a default text encoding
Notable performance improvements in many areas.
Time functions with nanosecond resolution
Data Classes
PyCharm provides smart code completion, code inspections, on-the-fly error
highlighting and quick-fixes, along with automated code refactoring and rich navigation
capabilities. PyCharm is cross-platform, with Windows, macOS and Linux versions. The
Community Edition is released under the Apache License, and there is also Professional
Edition with extra features, released under a proprietary license.
Tkinter is the standard GUI library for Python. Python when combined with Tkinter
provides a fast and easy way to create GUI applications. Tkinter provides a powerful objectoriented interface to the Tk GUI toolkit. Tkinter is the Python interface to the Tk GUI toolkit
shipped with Python. We would look this option in this chapter.
SQLite is an in-process library that implements a self-contained, serverless, zeroconfiguration, transactional SQL database engine. The code for SQLite is in the public
domain and is thus free for use for any purpose, commercial or private. SQLite is the most
widely deployed database in the world with more applications than we can count, including
several high-profile projects.
SQLite is an embedded SQL database engine. Unlike most other SQL databases,
SQLite does not have a separate server process. SQLite reads and writes directly to ordinary
disk files. A complete SQL database with multiple tables, indices, triggers, and views, is
contained in a single disk file.
3. Component Description/Working
System view:
In this application there is basically two main modules:
1. Adding a Record
2. Viewing a Record
1. Adding a record in database
In this module there is the fields which will take the inputs from the user such as
Books Attributes like name, cost, quantity etc. We also write SQL query for creating a
database for the first time user enter into this application. After filling all the attributes there
is also a SAVE button provided by clicking on it the data in the fields will be save in a
2. Viewing a record from the database
In these module we prepared a function in which we write the SQL query for viewing
all the data in their respected attributes. We design a table for to view this data in a table
format. In these way we are able to view these table.
Then we have Exit Button for quitting from the application.
We have imported different libraries and modules in this code so as to make use of
those widgets and functions.
 from tkinter import *
 import sqlite3
tkinter is import for making GUI widgets available for this application. It makes easier to
have import all the widget from the tkinter by using a * with it.
The importing of Sqlite3 is for the database connection necessity. By providing this library
we get to have a connection with the database easily without any complexity.
4. Code
from tkinter import *
import sqlite3
root = Tk()
# ------------FRAMES-3-----------TopFrame = Frame(root, width=1350, height=100, bd=4, relief='raise',bg='black')
TopFrame.grid(row=0, column=0, columnspan=4)
LeftFrame = Frame(root, width=350, height=500, bd=14, relief='raise')
LeftFrame.grid(row=1, column=0, columnspan=2)
RightFrame = Frame(root, width=1000, height=800, bd=14, relief='raise',bg='orange')
RightFrame.grid(row=1, column=2, columnspan=2, pady=(10, 0))
conn = sqlite3.connect("stock.db")
# -----------SAVE PRODUCT--------def savepro():
name = lblPname2.get()
cost = int(lblPcost2.get())
quantity = int(lblPqua2.get())
description = lblPdes2.get("1.0", END)
author = lblsup2.get()
print("\n" + name + "\n" + str(cost) + "\n" + str(quantity) + "\n" + description + "\n" +author)
conn.execute('''create table if not exists product
(name text,cost int, quantity int, description text, author text);
conn.execute("INSERT INTO product VALUES(?, ?, ?, ?, ?)", (name, cost, quantity, description, author))
# lblPid2 = Label(RightFrame, font=('arial',14), text="", bd=10, width=18, relief = 'sunken')
lblPname2 = Entry(RightFrame, font=('arial', 14), bd=10, width=18, relief='sunken')
lblPcost2 = Entry(RightFrame, font=('arial', 14), text="", bd=10, width=18, relief='sunken')
lblPqua2 = Entry(RightFrame, font=('arial', 14), bd=10, width=18, relief='sunken')
lblsup2 = Entry(RightFrame, font=('arial', 14), bd=10, width=18, relief='sunken')
lblPdes2 = Text(RightFrame, font=('arial', 14), bd=10, width=18, height=3, relief='sunken')
# ---------------------ADD NEW PRODUCT-----------------------------def AddNewProd():
lblPname = Label(RightFrame, font=('arial', 18), text="Book Name", bd=5, width=15, anchor=W)
lblPname.grid(row=1, column=0)
lblPname2.grid(row=1, column=1)
lblPcost = Label(RightFrame, font=('arial', 18), text="Book Cost", bd=5, width=15, anchor=W)
lblPcost.grid(row=2, column=0)
lblPcost2.grid(row=2, column=1)
lblPqua = Label(RightFrame, font=('arial', 18), text="Quantity", bd=5, width=15, anchor=W)
lblPqua.grid(row=3, column=0)
lblPqua2.grid(row=3, column=1)
lblPdes = Label(RightFrame, font=('arial', 18), text="Description", bd=5, width=15, anchor=W)
lblPdes.grid(row=4, column=0)
lblPdes2.grid(row=4, column=1)
lblsup = Label(RightFrame, font=('arial', 18), text="Book Author", bd=5, width=15, anchor=W)
lblsup.grid(row=8, column=0)
lblsup2.grid(row=8, column=1)
btn6 = Button(RightFrame, font=('arial', 18), text="SAVE", bd=10, width=18, justify='center',
btn6.grid(row=10, column=0, columnspan=2)
# ===========NEW WINDOW===============
def logger():
global root1
root1 = Tk()
rows = conn.execute("SELECT name,cost,quantity FROM product")
# rows = conn.fetchall()
# conn.commit()
enl = Label(root1, text="NAME")
enl.grid(row=0, column=1)
enl = Label(root1, text="COST")
enl.grid(row=0, column=2)
enl = Label(root1, text="QUANTITY")
enl.grid(row=0, column=3)
en = Text(master=root1, width=20)
en.grid(row=1, column=1)
ec = Text(master=root1, width=20)
ec.grid(row=1, column=2)
eq = Text(master=root1, width=20)
eq.grid(row=1, column=3)
msgn = ""
msgc = ""
msgq = ""
for r in rows:
msgn = msgn + "\n" + r[0]
msgc = msgc + "\n" + str(r[1])
msgq = msgq + "\n" + str(r[2])
en.insert(END, msgn)
ec.insert(END, msgc)
eq.insert(END, msgq)
# ==========================LEFT FRAME 4B/2L============
lblTitle = Label(TopFrame, font=('arial', 40, 'bold'), text="BOOK STORE MANAGEMENT", bd=10,
lblTitle.grid(row=0, column=0)
lblTitle = Label(LeftFrame,font=('arial', 20, 'italic'), text="BOOK MANAGEMENT", bd=10, width=22,
lblTitle.grid(row=0, column=0)
btn1 = Button(LeftFrame, font=('arial', 18), text="ADD A RECORD", bd=10, width=22, justify='center',
btn1.grid(row=1, column=0)
btn2 = Button(LeftFrame, font=('arial', 18), text="LIST OF BOOKS IN STOCK", bd=10, width=22,
btn2.grid(row=2, column=0)
btn5 = Button(LeftFrame, font=('arial', 18), text="EXIT", bd=10, width=22, justify='center', command=quit)
btn5.grid(row=10, column=0)
5. Output
1. Application :
2. Adding a record
3. viewing a record
4. Viewing records in database