Cybersecurity App
Cybersecurity App
Cybersecurity App
connector
def create_connection():
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="cybersecurity_app"
if conn.is_connected():
return conn
except Error as e:
print(f"Error: {e}")
return None
query = """
"""
def main():
conn = create_connection()
if conn is None:
return
cursor = conn.cursor()
try:
# Sample quiz questions
questions = [
("What does the term 'ransomware' refer to?", "A type of network",
"Malware that encrypts files and demands payment", "A software for protection",
insert_question(cursor, *question)
conn.commit()
except Error as e:
finally:
cursor.close()
conn.close()
if __name__ == "__main__":
main()
import mysql.connector
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="cybersecurity_app"
if conn.is_connected():
return conn
except Error as e:
print(f"Error: {e}")
return None
def get_questions(cursor):
return cursor.fetchall()
def take_quiz(cursor):
questions = get_questions(cursor)
score = 0
print(f"\n{question[1]}")
print(f"1. {question[2]}")
print(f"2. {question[3]}")
print(f"3. {question[4]}")
print(f"4. {question[5]}")
try:
score += 1
except ValueError:
def main():
conn = create_connection()
if conn is None:
return
cursor = conn.cursor()
try:
take_quiz(cursor)
finally:
cursor.close()
conn.close()
if __name__ == "__main__":
main()