update_course_offering_date.py 640 Bytes
Newer Older
1
2
import mysql.connector

Stefan Vercillo's avatar
Stefan Vercillo committed
3
4
5

cnx = mysql.connector.connect(host='localhost', user='snvercil', database='Education', password="sdfsdf")

6
7
8
cursor = cnx.cursor()


Stefan Vercillo's avatar
Stefan Vercillo committed
9
# cursor.execute("USE ece356;")
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cursor.execute("SELECT * FROM courseOfferings;")


c = cursor.fetchall()
for row in c:
    year = row[1][:4]
    semester = row[1][-1:]

    if semester == "J":
        semester = "Fall"
    else:
        semester = "Winter"

    query_string = f"update courseOfferings set year = {year}, semester = '{semester}' where course_offering_id = {row[3]} ;"
    print(query_string)
    cursor.execute(query_string)



cnx.commit()

cursor.close()
cnx.close()