import sqlite3
# Connecting to sqlite
connection_obj = sqlite3.connect('geek.db')
# cursor object
cursor_obj = connection_obj.cursor()
# Drop the GEEK table if already exists.
cursor_obj.execute("DROP TABLE IF EXISTS GEEK")
# Creating table
table = """ CREATE TABLE GEEK (
Email VARCHAR(255) NOT NULL,
Name CHAR(25) NOT NULL,
Score INT
); """
cursor_obj.execute(table)
# Inserting data into geek table
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek1",25)""")
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek2",15)""")
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek3",36)""")
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek4",27)""")
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek5",40)""")
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek6",14)""")
connection_obj.execute(
"""INSERT INTO GEEK (Email,Name,Score) VALUES ("[email protected]","Geek7",10)""")
# Display table
data = cursor_obj.execute("""SELECT * FROM GEEK""")
print('GEEK Table:')
for row in data:
print(row)
connection_obj.commit()
# Close the connection
connection_obj.close()