Skip to content

Commit 1f9dcc8

Browse files
committed
Add cleanup and process for 0002
1 parent abb003a commit 1f9dcc8

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

JiYouMCC/0002/0002.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,32 @@ def selectCodes(table='app_mccatcivitas.showmethecode'):
4747
for row in rows:
4848
result.append(str(row[0]))
4949
return result
50+
51+
52+
def cleanUp(table='app_mccatcivitas.showmethecode'):
53+
connection = MySQLdb.connect(
54+
host=sae.const.MYSQL_HOST,
55+
user=sae.const.MYSQL_USER,
56+
passwd=sae.const.MYSQL_PASS,
57+
port=int(sae.const.MYSQL_PORT),
58+
init_command='set names utf8')
59+
cur = connection.cursor()
60+
try:
61+
cur.execute("""drop table %s""" % (table))
62+
except Exception, e:
63+
print e
64+
connection.commit()
65+
cur.execute(
66+
"""create table %s (code char(32) not null primary key)""" % (table))
67+
connection.commit()
68+
cur.close()
69+
connection.close()
70+
71+
72+
def Process():
73+
cleanUp()
74+
code = create_code()
75+
for c in code:
76+
insertCode(c)
77+
result = selectCodes()
78+
return result

0 commit comments

Comments
 (0)