-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_sqlite3.py
More file actions
64 lines (29 loc) · 1.11 KB
/
database_sqlite3.py
File metadata and controls
64 lines (29 loc) · 1.11 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Data base Sql lite 3
'''
import sqlite3
conn=sqlite3.connect("lite2.db")
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS store(item TEXT, quantity INTEGER,price REAL)")
cur.execute ("INSERT INTO store VALUES ('Glass',8,10.5)")
conn.commit()
conn.close()
print("connection Closed .")
'''
import sqlite3
#conn=sqlite3.connect("tut2.db")
conn=sqlite3.connect("tut355.db")# connection to a database
c=conn.cursor() # cursor creation.
def create_table():
c.execute("CREATE TABLE IF NOT EXISTS TableName4(Srno INTEGER, Name TEXT, studentClass TEXT, Address TEXT)")
# query exection with help of c.execute()
def data_entry():
c.execute("INSERT INTO TableName4 VALUES(1,'ravi','1','Jntu')")
c.execute("INSERT INTO TableName4 VALUES(2,'srinivas','1A','Jntu')")
print("inside data entry function")
conn.commit()# Storing the data permanently.
c.execute("INSERT INTO TableName4 VALUES(3,'mohan','1','kukatpally')")
conn.commit()
c.close()
conn.close()
create_table()
data_entry()