-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_base.py
35 lines (30 loc) · 1.22 KB
/
data_base.py
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
import sqlite3
class Database:
def __init__(self, db):
self.con=sqlite3.connect(db)
self.cur=self.con.cursor()
sql = """
CREATE TABLE IF NOT EXISTS employees
(id integer primary key,
name text,
age text,
doj text,
email text,
gender text,
contact text,
address text)"""
self.cur.execute(sql)
self.con.commit()
def insert(self, name, age, doj, email, gender, contact, address):
self.cur.execute("insert into employees values(NULL,?,?,?,?,?,?,?)", (name, age, doj, email, gender, contact, address))
self.con.commit()
def fetch(self):
self.cur.execute("Select * from employees")
rows = self.cur.fetchall()
return rows
def delete(self, id):
self.cur.execute("delete from employees where id = ?", (id,))
self.con.commit()
def update(self, id, name, age, doj, email, gender, contact, address):
self.cur.execute("update employees set name=?,age=?,doj=?,email=?,gender=?,contact=?,address=? where id = ?",(name, age, doj, email, gender, contact, address,id))
self.con.commit()