Skip to content

Commit 887eb6e

Browse files
committed
error handling when query fails
1 parent 88470b6 commit 887eb6e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

python_scripts/get_traumatic_pages.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ def main():
109109
AND cl_to = "%s"
110110
""" % (subcat,)
111111
#print query
112-
cursor.execute(query)
112+
try:
113+
cursor.execute(query)
114+
except:
115+
print "ERROR! Subcat:", subcat
116+
continue
113117
result_set = cursor.fetchall()
114118
#print result_set
115119
print len(result_set)
@@ -137,14 +141,19 @@ def main():
137141

138142
if page_id != -1:
139143
query = """
140-
SELECT COUNT(*) AS tot_edits,
144+
SELECT COUNT(DISTINCT rev_id) AS tot_edits,
141145
COUNT(DISTINCT rev_user) AS editors
142146
FROM revision, user, user_groups
143147
WHERE rev_page=%s AND
144148
rev_user=user_id AND
145149
user_id=ug_user AND
146150
ug_group!="bot";""" % page_id
147-
cursor.execute(query)
151+
try:
152+
cursor.execute(query)
153+
except:
154+
print "Error! ", page
155+
continue
156+
148157
edits_row = list(cursor.fetchone())
149158

150159
if t == 0:

0 commit comments

Comments
 (0)