File size: 1,165 Bytes
ee000bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sqlite3

## Connecting to sqlite
connection = sqlite3.connect("student.db")

# Cursor will be responsible to insert record, create table, retrive 
cursor = connection.cursor()

##Creating Table
table_info="""
Create table STUDENT(NAME VARCHAR(25), CLASS VARCHAR(25), SECTION VARCHAR(25),MARKS INT);
"""

cursor.execute(table_info)

## Inserting some records

cursor.execute('''Insert Into STUDENT values('Atharva','AI/ML','A','95')''')
cursor.execute('''Insert Into STUDENT values('Ashutosh','SWE','B','80')''')
cursor.execute('''Insert Into STUDENT values('Samarth','Data Science','B','35')''')
cursor.execute('''Insert Into STUDENT values('Yash','Data Science','A','76')''')
cursor.execute('''Insert Into STUDENT values('Asnee','AI/ML','B','100')''')
cursor.execute('''Insert Into STUDENT values('Sam','AI/ML','A','98')''')
cursor.execute('''Insert Into STUDENT values('Emily','DEVOPS','A','50')''')
cursor.execute('''Insert Into STUDENT values('Manasi','DEVOPS','B','97')''')

## Display all records

data = cursor.execute('''select * From STUDENT''')

for row in data:
  print(row)

## Closing the connection
  
connection.commit()
connection.close()