-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrim-sql.py
More file actions
26 lines (26 loc) · 774 Bytes
/
trim-sql.py
File metadata and controls
26 lines (26 loc) · 774 Bytes
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
#coding=utf8
sqlf=open('IPL2.sql','r')
tables=['SYS_TEMPLATE', 'PRIZE_DETAIL', 'GAME_TEAM']
while True and not tables:
table=raw_input('input the table name(end by -1):\n')
if table=='-1':
break
tables.append(table)
print tables
text=sqlf.readlines()
tmpText=""
for line in text:
flag=False
if line.find('INSERT')>=0 :#含这些词
for table in tables:
if line.find(table)>=0:
flag=True
continue
if flag:
tmpText+=line
elif line.find("*!40")<0 and line.find('LOCK TABLES')<0 and line.find('--')<0 and line.find('INSERT')<0:#不含这些词
tmpText+=line
toSqlFile=open('newIpl2.sql','w')
toSqlFile.write(tmpText)
toSqlFile.close()
sqlf.close()