Aaron Bosh Macsimus: Xii - C, Chinmaya Vidyalaya, Kolazhi
Aaron Bosh Macsimus: Xii - C, Chinmaya Vidyalaya, Kolazhi
Aaron Bosh Macsimus: Xii - C, Chinmaya Vidyalaya, Kolazhi
1 Certificate 1
2 Acknowledgement 3
3 Project Definition 5
4 Coding 7
5 Requirements 15
6 Screen Shots 17
7 Conclusion 27
8 Bibliography 29
i
Project Definition
3
The COVID-19 pandemic in India is part of the worldwide pandemic of coronavirus disease
2019 (COVID-19) caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-
2). The first case of COVID-19 in India, which originated from China, was reported on 30
January 2020. India currently has the largest number of confirmed cases in Asia, and has the
second-highest number of confirmed cases in the world after the United States, with more
than 9 million reported cases of COVID-19 infection and more than 100 thousand deaths.
By mid of 2020, India had approached in position of conducting highest number of daily
tests in the world which subsequently translated into highest number of daily new cases in
world and has sustained highest number of daily cases spike since then.
On 22 March, India observed a 14-hour voluntary public curfew at the insistence of Prime
Minister Narendra Modi. It was followed by mandatory lockdowns in COVID-19 hotspots
and all major cities. Further, on 24 March, the prime minister ordered a nationwide lockdown
for 21 days, affecting the entire 1.3 billion population of India. On 14 April, India extended
the nationwide lockdown till 3 May which was followed by two-week extensions starting 3
and 17 May with substantial relaxations. From 1 June, the government started “unlocking”
the country (barring “containment zones”) in three unlock phases.
The project named as COVID 19 INDIA STATE WISE is to get the latest number of
confirmed, deaths, recovered and active cases of Novel Coronavirus (COVID-19) state wise.
And it uses database named as covid19 created using MySQL and contains a table statistics
which has the following structure:
Table 1: statistics
Field Type Null Key Default
cname varchar(20) NO PRI NULL
confirmed int YES NULL
recovered int YES NULL
deaths int YES NULL
active int YES NULL
5
Aaron Bosh Macsimus
def create_widgets():
button=Button(text="Open Database",fg="red",command=myCon)
button.grid(row=0,column=0,sticky=W)
button2=Button(text="Close Database",command=comit)
button2.grid(row=0,column=3,sticky=W)
button2=Button(text="Create Database",command=createDb)
button2.grid(row=0,column=4,sticky=W)
button2=Button(text="Create Table",command=createTab)
button2.grid(row=0,column=5,sticky=W)
button2=Button(text="Add Record",command=addrec)
button2.grid(row=0,column=6,sticky=W)
button2=Button(text="Display Record",command=displayrec)
button2.grid(row=0,column=7,sticky=W)
button2=Button(text="Search Record",command=searchrec)
button2.grid(row=0,column=9,sticky=W)
(continues on next page)
7
Aaron Bosh Macsimus
button2=Button(text="Update Record",command=updaterec)
button2.grid(row=0,column=10,sticky=W)
def myCon():
mydb=mc.connect(host='localhost',user='aaron',passwd='Bosh$2346536')
mycur=mydb.cursor()
mycur.execute("use covid19")
return mycur,mydb
def comit():
mycur,mydb=myCon()
mydb.commit()
mycur.close()
mydb.close()
def createDb():
mycur,mydb=myCon()
mycur.execute("CREATE DATABASE IF NOT EXISTS covid19")
mycur.execute("use covid19")
def createTab():
mycur,mydb=myCon()
mycur.execute("create table if not exists statistics(cname varchar(20),
confirmed int, recovered int, deaths int, active int)")
def sqlq():
sql="insert into statistics(cname,confirmed,recovered,deaths,active)
values(%s,%s,%s,%s,%s)"
return sql
def addrec():
mycur,mydb=myCon()
def submit_app():
#csvInsert()
try:
mycur.execute(sqlq(),(e1.get(),e2.get(),e3.get(),
e4.get(),int(e2.get())-int(e3.get())- int(e4.get()),))
mydb.commit()
rt.destroy()
except mc.IntegrityError as e:
messagebox.showinfo("SEARCH DETAILS",
"Record already exists!!!!")
mydb.rollback()
rt.destroy()
(continues on next page)
8 Chapter 4. Coding
Aaron Bosh Macsimus
e1 = Entry(rt)
e1.grid(row=4,column=1)
e2 = Entry(rt)
e2.grid(row=5,column=1)
e3 = Entry(rt)
e3.grid(row=6,column=1)
e4 = Entry(rt)
e4.grid(row=7,column=1)
Button(rt,text="SUBMIT",width=25,command=submit_app).grid
(row=11,column=0,columnspan=2)
rt.mainloop()
def csvInsert():
mycur,mydb=myCon()
with open('indiaCovid.csv') as f:
reader = csv.DictReader(f, delimiter=',')
for row in reader:
cname = row['cname']
confirmed = row['confirmed']
recovered = row['recovered']
deaths= row['deaths']
active=row['active']
mycur.execute("INSERT INTO statistics (cname,confirmed,
recovered,deaths,active) VALUES
('%s ', '%s ', '%s ', '%s ','%s ')" %
(cname,confirmed,recovered,deaths,active))
mydb.commit()
def displayrec():
global root
root = Tk()
root.title('COVID 19 DETAILS INDIAN STATES')
mycur,mydb=myCon()
mycur.execute('select * from Statistics')
row=mycur.fetchall()
mydb.commit()
treeview=ttk.Treeview(root)
treeview["column"] = ["State","Confirmed","Recovered","Deaths",
"Active"]
(continues on next page)
9
Aaron Bosh Macsimus
def deleterec():
mycur,mydb=myCon()
def submitdel():
sql='select * from statistics where cname ="%s "'%(e8.get())
mycur.execute(sql)
rec=mycur.fetchall()
if len(rec)!=0:
messagebox.showinfo("SEARCH DETAILS",
"STATE FOUND HERE")
sql1='delete from statistics where cname ="%s "
'%(e8.get())
mycur.execute(sql1)
mydb.commit()
messagebox.showinfo("DELETE DETAILS",
"ONE RECODE DELETED")
rt.destroy()
return True,rec
else:
messagebox.showinfo("SEARCH DETAILS",
"RECORD NOT FOUND HERE")
rt.destroy()
return False,"RECORD NOT FOUND HERE"
rt=tk.Tk()
Label(rt,text="STATE NAME").grid(row=10,column=6)
e8 = Entry(rt)
e8.grid(row=10,column=8)
Button(rt,text="SUBMIT",width=17,command=submitdel).grid(row=14,
column=8,columnspan=2)
10 Chapter 4. Coding
Aaron Bosh Macsimus
rt1=tk.Tk()
Label(rt1,text="ENTER STATE NAME TO SEARCH").grid
(row=10,column=7)
e7 = Entry(rt1)
e7.grid(row=10,column=9)
Button(rt1,text="SUBMIT",width=25,command=submitsch).grid
(row=11,column=7,columnspan=2)
rt1.mainloop()
11
Aaron Bosh Macsimus
12 Chapter 4. Coding
Aaron Bosh Macsimus
13
Aaron Bosh Macsimus
def main():
root=init()
create_widgets()
root.mainloop()
if __name__=="__main__":
main()
14 Chapter 4. Coding
Requirements
5
The project is developed in the following environment:
Operating Systems: 64 bit Windows 10.
Database: MySQL 8.0, 64 bit.
MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL
is developed, marketed and supported by MySQL AB, which is a Swedish company. It is
becoming so popular because of many good reasons.
It is released under an open-source license. So we have nothing to pay to use it.
It is a very powerful program in its own right. It handles a large subset of the functionality
of the most expensive and powerful database packages.
It uses a standard form of the well-known SQL data language.
MySQL works on many operating systems and with many languages including PYTHON,
PHP, PERL, C, C++, JAVA, etc.
Programming Language: Python 3.7 64 bit
Python was developed by Guido van Rossum in the late eighties and early nineties at the Na-
tional Research Institute for Mathematics and Computer Science in the Netherlands. Python
is a high-level, interpreted, interactive and object-oriented scripting language. Python is de-
signed to be highly readable. It uses English keywords frequently whereas the other languages
use punctuations. It has fewer syntactical constructions than other languages.
Python is Interpreted: Python is processed at runtime by the interpreter. We do not need
to compile your program before executing it.
Python is Interactive: You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
Python is Object-Oriented: Python supports Object-Oriented style or technique of program-
ming that encapsulates code within objects.
15
Aaron Bosh Macsimus
GUI: tkinter
GUI: User interfaces are what allows end users to interact with an application. An ap-
plication can be excellent, but without a good user interface, it becomes more difficult to
use, and less enjoyable. It is thus very important to design good user interfaces. Designing
user interface takes place at two different levels: the graphical level and the event level.
Graphical elements of a user interface are called widgets. Widgets are basic components like
buttons, scrollbars, etc. But user interfaces involve more than a collection of widgets placed
in a window. The application must be able to respond to mouse clicks, keyboard actions or
system events such as minimizing the window. For this to happen, events must be associated
to some pieces of code. This process is called binding. The next two chapters will cover each
level in more details, but this chapter will present an overview of Tkinter and explain why
it has become the leading GUI toolkit for the Python language.
Tkinter: is an open source, portable graphical user interface (GUI) library designed for use
in Python scripts. Tkinter relies on the Tk library, the GUI library used by Tcl/Tk and Perl,
which is in turn implemented in C. Thus, Tkinter is implemented using multiple layers.
Tkinter is the standard GUI library for Python. Python when combined with Tkinter pro-
vides a fast and easy way to create GUI applications. Tkinter provides a powerful object-
oriented interface to the Tk GUI toolkit. Creating a GUI application using Tkinter is an
easy task. All we need to do is perform the following steps:
Import the Tkinter module.
Create the GUI application main window.
Add one or more of the above-mentioned widgets to the GUI application.
Enter the main event loop to take action against each event triggered by the user.
LaTeX a document preparation system:
LaTeX is a high-quality typesetting system; it includes features designed for the production
of technical and scientific documentation. LaTeX is the de facto standard for the communi-
cation and publication of scientific documents. LaTeX is available as free software.
16 Chapter 5. Requirements
6
Screen Shots
17
Aaron Bosh Macsimus
19
Aaron Bosh Macsimus
21
Aaron Bosh Macsimus
23
Aaron Bosh Macsimus
25