Commit 9ba59836 authored by Stefan Vercillo's avatar Stefan Vercillo
Browse files
parents b229cc6f 6cd212e3
import mysql.connector
mydb = mysql.connector.connect(
host="",
user="",
database=""
)
db_client = mydb.cursor()
from parser import parser
# from db_client import db_client
from utils import *
if __name__ == "__main__":
while True:
command = input("Command: ").split()
if handle_errors(command):
continue
if command[0] == "exit":
print("exiting...")
break
\ No newline at end of file
import argparse
# the base table specifications - for the table at hand
# ========== INSERT ENTRY SECTION ==========
insert_entry_parser = argparse.ArgumentParser()
insert_entry_parser.add_argument(
"--table",
dest="table",
choices=[
"studentInfo",
"studentRegistration",
"studentAssessment",
"studentVle",
"assessments",
"courses",
"vle"
],
help="specify the table to perform CRUD on",
required=True
)
# ========== MODIFY TABLE SECTION ==========
modify_table_parser = argparse.ArgumentParser()
modify_table_parser.add_argument(
"--table",
dest="table",
choices=[
"studentInfo",
"studentRegistration",
"studentAssessment",
"studentVle",
"assessments",
"courses",
"vle"
],
help="specify the table to perform CRUD on",
required=True
)
# ========== DELETE ROW SECTION ==========
delete_row_parser = argparse.ArgumentParser()
delete_row_parser.add_argument(
"--table",
dest="table",
choices=[
"studentInfo",
"studentRegistration",
"studentAssessment",
"studentVle",
"assessments",
"courses",
"vle"
],
help="specify the table to perform CRUD on",
required=True
)
# ========== GET COURSES SECTION ==========
get_courses_parser = argparse.ArgumentParser()
get_courses_parser.add_argument(
"--course_id",
dest="course_id",
type=int,
help="course id, must be an int"
)
get_courses_parser.add_argument(
"--code_module",
dest="code_module",
help="unique to each module"
)
get_courses_parser.add_argument(
"--year_and_semester",
dest="time",
)
# ========== GET ASSESSMENTS SECTION ==========
get_assessments_parser = argparse.ArgumentParser()
# ========== GET VLE SECTION ==========
get_vle_parser = argparse.ArgumentParser()
# ========== GET STUDENTS SECTION ==========
get_students_parser = argparse.ArgumentParser()
from parser import *
options = [
"insert-entry",
"modify-table",
"delete-row",
"get-courses",
"get-assessments",
"get-vle",
"get-students"
]
new_options = [
"insert",
"modify",
"delete",
"get"
]
# def get(cmd):
# pass
# base_table = input()
# list_of_shit_you_can_filter_on = list_of_shit_you_can_filter_on(base_table)
# list_of_user_filters = list()
# # branch on filtering
# for item in list_of_shit_you_can_filter_on:
# print(f"filtering on {item}")
# col_name = input("col name")
# operator = input("GT, LT, like, or ET")
# value = input("the attibute value")
# branching for get:
# 1. ask the base table
# 2.
def handle_errors(command):
if command[0] not in options:
print(f"Error: command not in options. Options are:\n {options}")
return True
return False
def insert_entry(command):
insert_entry_args = insert_entry_parser.parse_args(command[1:])
# branch based on the table
if insert_entry.table == "studentInfo":
student_id = input("what is the student ID (required): ")
course_id = input("what is the course ID? (not required): ")
def modify_table(command):
modify_table_args = modify_table_parser.parse_args(command[1:])
# branch based on the table
def delete_row(command):
delete_row_args = delete_row_parser.parse_args(command[1:])
# branch based on the table
def get_courses(command):
get_courses_args = get_courses_parser.parse_args(command[1:])
all = "all" in command
# branch based on what to filter on
def get_assessments(command):
get_assessments_args = get_assessments_parser.parse_args(command[1:])
all = "all" in command
# branch based on what to filter on
def get_vle(command):
get_vle_args = get_vle_parser.parse_args(command[1:])
all = "all" in command
# branch based on what to filter on
def get_students(command):
get_students_args = get_students_parser.parse_args(command[1:])
all = "all" in command
# branch based on what to filter on
#!/bin/bash
# ** README **
# Requirements:
# 1. mysql-connector pip module installed
# 2. local path to loading data files updated in script1
# 3. input your database name for the db_name variable
# 4. update connection info inside the python scripts
db_name="ece356"
mysql -u root --verbose --verbose $db_name < "scripts/script1.sql"
mysql -u root --verbose --verbose $db_name < "scripts/script2.sql"
mysql -u root --verbose --verbose $db_name < "scripts/script3.sql"
#tested up to there ^
python3 scripts/update_course_offering_date.py
python3 scripts/update_imd_band.py
mysql -u root --verbose --verbose $db_name < "scripts/script4.sql"
......@@ -77,6 +77,8 @@ update assessments
alter table assessments
drop column assessment_type_o;
drop table Courses;
alter table studentInfo
drop column highest_education;
......
import mysql.connector
cnx = mysql.connector.connect(host='localhost', user='snvercil', database='education', password="32darklink")
# cnx = mysql.connector.connect(host='localhost', user='snvercil', database='Education', password="32darklink")
cnx = mysql.connector.connect(host='127.0.0.1', user='root', database='ece356')
cursor = cnx.cursor()
cursor.execute("USE ece356;")
cursor.execute("SELECT * FROM courseOfferings;")
......
import mysql.connector
cnx = mysql.connector.connect(host='localhost', user='snvercil', database='Education', password="32darklink")
# cnx = mysql.connector.connect(host='localhost', user='snvercil', database='Education', password="32darklink")
cnx = mysql.connector.connect(host='127.0.0.1', user='root', database='ece356')
cursor = cnx.cursor()
cursor.execute("USE EDUCATION;")
cursor.execute("USE ece356;")
cursor.execute("SELECT * FROM studentInfo;")
c = cursor.fetchall()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment