-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelRecords.py
87 lines (64 loc) · 2.07 KB
/
delRecords.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python
# -*- coding: utf-8 -*-
import mysql.connector
from mysql.connector import errorcode
from mako.template import Template
from mako.lookup import TemplateLookup
mylookup = TemplateLookup(directories=['.'])
assignmentsTmpl = Template(filename='assignments.tmpl', lookup=mylookup)
assignmentPartTableTmpl = Template(filename='assignmentPartTable.tmpl',
lookup=mylookup)
assignmentAllTableTmpl = Template(filename='assignmentAllTable.tmpl',
lookup=mylookup)
assignmentStartTmpl = Template(filename='assignmentStart.tmpl',
lookup=mylookup)
assignmentEndTmpl = Template(filename='assignmentEnd.tmpl',
lookup=mylookup)
# assignmentTmpl = Template(filename='header.tmpl')
# FooterTmpl = Template(filename='footer.tmpl')
user = 'testing'
password = ''
host = 'dopt-results.cwf0g50wotli.us-east-1.rds.amazonaws.com'
database = 'dopt_results'
cnx = None
cursor = None
try:
cnx = mysql.connector.connect(user=user, password=password,
host=host, database=database)
# print(self.cnx)
cursor = cnx.cursor()
except mysql.connector.Error, err:
# print(self.cursor)
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print 'Something is wrong your username or password'
print err
exit()
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print 'Database does not exists'
print err
exit()
else:
print err
exit()
userId = 123100000
partIds = [
'8zVuNh0L',
'eaOs8z3l',
'pxIsuCQe',
'clCLq0Vb',
'2gHetJOV',
'ASSX0Lq4',
'OXs89Owz',
'AO0FA8y8',
]
remove_user_query = 'DELETE FROM ' + database \
+ '.`user` WHERE courseraUserID >= ' + str(userId)
remove_result_query = 'DELETE FROM ' + database \
+ '.`result` WHERE courseraUserID >= ' + str(userId)
data = ()
# Insert new employee
cursor.execute(remove_user_query, data)
cnx.commit()
# Insert new employee
cursor.execute(remove_result_query, data)
cnx.commit()