- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLite.py
More file actions
Latest commit
executable file
·34 lines (27 loc) · 946 Bytes
/
Copy pathSQLite.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
importsqlite3
conn=sqlite3.connect("test.db")
c=conn.cursor()
defcreate_table():
c.execute('CREATE TABLE roll_list(Name VARCHAR, Roll INT, Branch TEXT)')
#create_table()
defenter_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()
defread_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 = ? "
forrowinc.execute(sql,[(name)]):
print(row)
read_data()
defupdate():
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()