Exemple #1
0
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())
Exemple #2
0
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())
Exemple #3
0
def count_students():
    students_qty = dbi.sql_execute(
        "SELECT COUNT(id) FROM students").fetchone()[0]
    print("\nNUMBER OF STUDENTS:", students_qty)
Exemple #4
0
def count_unique_names():
    students_qty = dbi.sql_execute(
        "SELECT COUNT(DISTINCT name) FROM students").fetchone()[0]
    print("\nNUMBER OF UNIQUE NAMES:", students_qty)
Exemple #5
0
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())