Praveenkumar07's picture
Upload 3 files
8934fc5 verified
Raw History Blame Contribute Delete
959 Bytes
import sqlite3
#connect to SQLlite
connection=sqlite3.connect("student.db")
#create a cursor to insert record,create table
cursor=connection.cursor()
#create a table
table_info="""
Create table STUDENT(NAME VARCHAR(25),CLASS VARCHAR(25),
SECTION VARCHAR(25));
"""
#creating the table
cursor.execute(table_info)
#insert some more records
cursor.execute("""Insert Into STUDENT values("Krish","Data Science","A")""")
cursor.execute("""Insert Into STUDENT values("kayal","DevOps","A")""")
cursor.execute("""Insert Into STUDENT values("david","Data Science","B")""")
cursor.execute("""Insert Into STUDENT values("bala","DevOps","A")""")
cursor.execute("""Insert Into STUDENT values("praveen","Data Science","B")""")
#Display the records
print("The inerted records are")
data=cursor.execute("""select * from STUDENT""")
for row in data:
print(row)
#commit the changes in db
connection.commit()
connection.close()