Skip to content
Snippets Groups Projects
Commit 59226a0f authored by haoyuz3's avatar haoyuz3
Browse files

debug

parent 00030495
No related branches found
No related tags found
No related merge requests found
SELECT Students.FirstName, Students.LastName, Courses.Instructor FROM Students INNER JOIN Enrollments ON Students.NetId=Enrollments.NetId INNER JOIN Courses ON Enrollments.CRN=Courses.CRN WHERE (Students.FirstName LIKE 'A%' OR Students.LastName LIKE 'A%') AND (Courses.Instructor LIKE 'A%');
SELECT DISTINCT S.NetId, S.FirstName, S.LastName FROM Students S, Enrollments E, Courses C WHERE S.NetId = E.NetId AND E.CRN = C.CRN AND S.Department = 'CS' AND C.Department = 'ECE' AND E.Score <= All (SELECT E2.Score FROM Enrollments E2 WHERE E2.CRN = E.CRN) ORDER BY S.LastName, S.NetId DESC;
SELECT Students.FirstName, Students.LastName, Courses.Instructor FROM Students INNER JOIN Enrollments ON Students.NetId=Enrollments.NetId INNER JOIN Courses ON Enrollments.CRN=Courses.CRN WHERE (Students.FirstName LIKE 'A%' OR Students.LastName LIKE 'A%') AND (Courses.Instructor LIKE 'A%');
SELECT DISTINCT S.NetId, S.FirstName, S.LastName FROM Students S, Enrollments E, Courses C WHERE S.NetId = E.NetId AND E.CRN = C.CRN AND S.Department = 'CS' AND C.Department = 'ECE' AND E.Score <= All (SELECT E2.Score FROM Enrollments E2 WHERE E2.CRN = E.CRN) ORDER BY S.LastName, S.NetId DESC;
......@@ -158,16 +158,17 @@ def preprocess_query(query, cur, conn):
tables = tablesInQuery(query)
output = []
for table in tables:
print(table)
if table not in tablesWithProvenance:
cmdAddProvtuple = "select \"add_provtuple\"('{}')".format(table)
command1 = "select add_provenance('{}');".format(table)
command2 = "select create_provenance_mapping('{}_provtuple_mapping','{}','provtuple');".format(table, table)
command2 = "select create_provenance_mapping('{}_provtuple_mapping','{}','provtuple');".format(table.lower(), table)
ut.commitAndExecute(conn, cur, cmdAddProvtuple)
ut.commitAndExecute(conn, cur, command1)
ut.commitAndExecute(conn, cur, command2)
tablesWithProvenance[table] = 1
formula = " formula(provenance(), '{}_provtuple_mapping'), ".format(table)
index = query.find('select') + 6
formula = " formula(provenance(), '{}_provtuple_mapping'), ".format(table.lower())
index = query.lower().find('select') + 6
tmp = query[:index] + formula + query[index:]
output.append(tmp)
......@@ -292,4 +293,4 @@ def main():
print('Database connection closed.')
if __name__ == '__main__':
main()
\ No newline at end of file
main()
......@@ -39,7 +39,7 @@ def extractData(conn, cur):
filepath = mydir + "/" + f
fl = open(filepath)
sql_str = fl.read()
sql_str = sql_str.strip().replace("\n", " ")
#sql_str = sql_str.strip().replace("\n", " ")
flag = 0
try:
......@@ -59,6 +59,7 @@ def main():
conn = psycopg2.connect("dbname=provdb user=joker password=m")
cur = conn.cursor()
extractData(conn, cur)
print(query)
conn.close()
for question_id in [1,2,3,4,5,6,7,8]:
if question_id != 2:
......@@ -95,4 +96,4 @@ def main():
if __name__ == "__main__":
# execute only if run as a script
main()
\ No newline at end of file
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment