-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.py
More file actions
37 lines (33 loc) · 1.6 KB
/
connect.py
File metadata and controls
37 lines (33 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sqlite3
class myconnect:
def __init__(self):
self.con = sqlite3.connect("emp.db")
self.con.execute(''' create table if not exists emp(
id integer primary key AUTOINCREMENT,
name text,
email text,
mobile_no text,
type text,
experience integer,
salary text
) ''')
def savetodb(self,ename,eemail,emob,etype,eexp,esalary):
with self.con:
self.con.execute(
"insert into emp(name,email,mobile_no,type,experience,salary) values(:name,:email,:mobile_no,:type,:experience,:salary)",
{'name': ename, 'email': eemail, 'mobile_no': emob, 'type': etype, 'experience': eexp,
'salary': esalary})
self.con.commit()
def display(self):
eid = input("enter the emp id: ")
with self.con:
dataEmp = self.con.execute(
'select id,name,email,mobile_no,type,experience,salary from emp where id=:id',
{'id': eid})
l = dataEmp.fetchall()
print "Name : " + l[0][1]
print "Email : " + l[0][2]
print "Mobile No. : " + l[0][3]
print "Employee Type : " + l[0][4]
print "Experience : ", l[0][5]
print "Salary : ", l[0][6]