-
-
Save toyeiei/c430db7eafb30d315d45c7547de91428 to your computer and use it in GitHub Desktop.
IT Fundamentals Final Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
def verify_user(): | |
""" | |
verify if user input correct username/password | |
if True then run get_data function else program ends | |
""" | |
print("Student Exam Score Result") | |
print("Please type in your username and password to access result") | |
username = input("Username: ") | |
password = input("Password: ") | |
if username == "admin" and password == "2020": | |
get_data() | |
else: | |
print("Your username or password is incorrect") | |
def get_data(): | |
""" | |
connect to database and get data | |
format and present result in console | |
""" | |
conn = sqlite3.connect("university.db") | |
cur = conn.cursor() | |
cur.execute("SELECT id, firstname, exam_score FROM student;") | |
result = cur.fetchall() | |
conn.close() | |
print("Student Exam Score Report") | |
print("=" * 30) | |
for row in result: | |
print(f"name: {row[1]} \texam score: {row[2]}") | |
def main(): | |
"""our main program""" | |
verify_user() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment