File size: 849 Bytes
072b879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sqlite3
## connect to sqlite
connection = sqlite3.connect("test.db")

# Create a cursor object to insert record , create table


cursor = connection.cursor()

## create the table

table_info = """
Create table STUDENT(NAME VARCHAR(25),CLASS VARCHAR(25),
SECTION VARCHAR(25)
);
"""
cursor.execute(table_info)

cursor.execute('''Insert Into STUDENT values('sushil','data science','A')''')
cursor.execute('''Insert Into STUDENT values('ravi','data science','B')''')
cursor.execute('''Insert Into STUDENT values('sumit','data science','A')''')
cursor.execute('''Insert Into STUDENT values('rahul','devops','A')''')
cursor.execute('''Insert Into STUDENT values('vikram','devops','A')''')

print("the inserted records are")

data = cursor.execute('''Select  * from student''')
for row in data:
    print(row)

connection.commit()
connection.close()