-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
36 lines (31 loc) · 995 Bytes
/
test.py
File metadata and controls
36 lines (31 loc) · 995 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
27
28
29
30
31
32
33
34
35
36
import re
s1 = '''PASTE YOUR CODE HERE
'''
t = re.split(r".*\*\*\*.*", s1)
for i in range(1, len(t) - 1):
t[i] = "GO\n" + t[i]
s1 = t[i]
s2 = re.sub(r"[\[\]]", "", s1)
s2 = re.sub(r"GO(.*\n)*CREATE", "CREATE", s2)
s2 = re.sub(r"dbo\.", "", s2)
s2 = re.sub(r"CLUSTERED\s*\(\s*([\w_]*)(.*\n)\)(.*\n)(.*\n)", "(\g<1>)\n)\n;", s2)
s2 = re.sub(r"GO", "", s2)
s2 = s2.replace("int", "INTEGER").replace("varchar", "VARCHAR")
print (s2)
t = re.split(r"ALTER", t[-1])
t[0] = "GO\n" + t[0]
s1 = t[0]
s2 = re.sub(r"[\[\]]", "", s1)
s2 = re.sub(r"GO(.*\n)*CREATE", "CREATE", s2)
s2 = re.sub(r"dbo\.", "", s2)
s2 = re.sub(r"CLUSTERED\s*\(\s*([\w_]*)(.*\n)\)(.*\n)(.*\n)", "(\g<1>)\n)\n;", s2)
s2 = re.sub(r"GO", "", s2)
s2 = s2.replace("int", "INTEGER").replace("varchar", "VARCHAR")
print (s2)
for i in range(1, len(t)):
t[i] = "ALTER" + t[i]
s2 = re.sub(r"[\[\]]", "", t[i])
s2 = re.sub(r"dbo\.", "", s2)
s2 = re.sub(r"GO\n", "", s2)
s2 = s2.replace(" WITH CHECK ", "")
print (s2 + ";")