lx160cm's picture
Upload 4 files
0eaf528 verified
raw
history blame
938 Bytes
import sqlite3
## COnnect to SQlite
connection=sqlite3.connect("student.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)
##Insert Some Records
cursor.execute("""Insert into STUDENT values('Ramu','Data Science','A')""")
cursor.execute("""Insert into STUDENT values('Alex','GenAI','B')""")
cursor.execute("""Insert into STUDENT values('Shaan','NASA','A')""")
cursor.execute("""Insert into STUDENT values('Tanvika','DevOps','A')""")
cursor.execute("""Insert into STUDENT values('Teja','NASA','B')""")
cursor.execute("""Insert into STUDENT values('Kishore','CIVIL','B')""")
## Display Records
connection.commit()
print("The Inserted records are")
data = cursor.execute('''select *from STUDENT''')
for row in data:
print(row)