def add_field_to_students(): dbi.sql_execute("""ALTER TABLE students ADD favTch DEFAULT 2 """) print( "\nADDED COLUMN, EVERYONE LOVES ASH\n", dbi.sql_execute("""SELECT name, favTch FROM students""").fetchall())
def best_students(): print( "\n BEST STUDENTS:\n", dbi.sql_execute("""SELECT s.name FROM students AS s, projects AS p WHERE s.id = p.st AND p.grade = (SELECT MAX(grade) FROM projects)""" ).fetchall())
def count_students(): students_qty = dbi.sql_execute( "SELECT COUNT(id) FROM students").fetchone()[0] print("\nNUMBER OF STUDENTS:", students_qty)
def count_unique_names(): students_qty = dbi.sql_execute( "SELECT COUNT(DISTINCT name) FROM students").fetchone()[0] print("\nNUMBER OF UNIQUE NAMES:", students_qty)
def delete_jans(): dbi.sql_execute("""DELETE FROM students WHERE name LIKE 'J%n'""") print("\nSTUDENTS AFTER DELETION\n", dbi.sql_execute("""SELECT name FROM students""").fetchall())