# Importing necessary libraries
import sqlite3
# Creating a database connection
conn = sqlite3.connect('Student.db')
# Creating a cursor object
cursor = conn.cursor()
# Creating a table called Student_Details
cursor.execute("""CREATE TABLE Student_Details
(Roll_No INT NOT NULL,
Student_Name TEXT NOT NULL,
Student_Class TEXT NOT NULL)""")
# Committing the changes
conn.commit()
# Closing the cursor and database connection
cursor.close()
conn.close()
print("Table created successfully!")
Write a Python code to create a database file and a table named 'Student_Details with three columns, 'Roll No, 'Student Name' and 'Student Class'. Support your code with suitable comments.
1 answer