-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLite.py
More file actions
executable file
·34 lines (27 loc) · 946 Bytes
/
SQLite.py
File metadata and controls
executable file
·34 lines (27 loc) · 946 Bytes
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
import sqlite3
conn = sqlite3.connect("test.db")
c = conn.cursor()
def create_table():
c.execute('CREATE TABLE roll_list(Name VARCHAR, Roll INT, Branch TEXT)')
#create_table()
def enter_data():
name = input("Enter your name : ")
roll = int(input("Enter Roll no. : "))
branch = input("Enter branch : ")
c.execute("INSERT INTO roll_list(Name, Roll, Branch) VALUES (?, ?, ?)",(name, roll, branch))
conn.commit()
enter_data()
def read_data():
name = input("What name r u looking for? ")
#roll = input("What roll no. r u looking for? ")
sql = "SELECT * FROM roll_list WHERE name = ? "
for row in c.execute(sql,[(name)]):
print(row)
read_data()
def update():
sql = "UPDATE roll_list SET Name = ? WHERE Name = 'Mukta'"
#old = input("Enter name u want to change : ")
new = input("Enter new name : ")
c.execute(sql,[(new)])
conn.commit()
update()