SQLite DB graded assignment seems broken
nratzan opened this issue · 1 comments
I did the graded assignment for 15.3 and got data back that indicated I completed it correctly, i.e. the top organization had count=536, just like the hint said it should. When I uploaded the sqlite db file, the auto-grader said it was incorrect. Perhaps something else I did was incorrect, but I think it's maybe the assignment, since my db return matched the hint.
Github won't let me upload the .db file.
Here's the code:
`import sqlite3
import re
conn = sqlite3.connect('2emaildb.sqlite')
cur = conn.cursor()
cur.execute('DROP TABLE IF EXISTS Counts')
cur.execute('CREATE TABLE Counts (org TEXT, count INTEGER)')
fname = input('Enter file name: ')
if (len(fname) < 1): fname = 'mbox.txt'
fh = open(fname)
for line in fh:
if not line.startswith('From: '): continue
parts1 = line.split()
email = parts1[1]
org = str(re.findall('@([a-z,0-9]+).',email))
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org,))
row = cur.fetchone()
if row is None:
cur.execute('''INSERT INTO Counts (org, count)
VALUES (?, 1)''', (org,))
else:
cur.execute('UPDATE Counts SET count = count + 1 WHERE org = ?', (org,))
conn.commit()
sqlstr = 'SELECT org, count FROM Counts ORDER BY count DESC LIMIT 10'
for row in cur.execute(sqlstr):
print(str(row[0]), row[1])
cur.close()
`
I do not think the auto grader is broken. It has not been changed in months and is used successfully hundreds of times per day. I am sure there is something missing in the code. But we don't help with student assignments in github. You should get help wherever the course material is being presented.