hytos / minorTools / makeClearSql.py @ f26557b1
이력 | 보기 | 이력해설 | 다운로드 (2.49 KB)
1 |
def make_sql_delete_drawing_data(): |
---|---|
2 |
import os |
3 |
|
4 |
sqlPath = os.path.join('E:\Projects\DTIPID\minorTools', 'clear.txt') |
5 |
|
6 |
drawing_uids = ['c2f352a0-a609-4329-8aec-32941beece0c']
|
7 |
|
8 |
|
9 |
#drawing_uids = ['b76d771f-afe7-4e53-80c3-5602d4f070f4', '7f1421b9-d75e-4b54-9c9a-189482e10f74', \
|
10 |
# '6fa42c26-b366-409c-b4b7-058d88c2abf0', '203d37ed-a5dc-4c6a-b54c-59ca787d1e33', '9e249ac6-8915-4159-a3ef-c070b8b6fa48', \
|
11 |
# '59e70d86-2849-496a-8e58-343ccf492935', '8650818d-917e-4837-a2f9-35bc24e94961', 'a17df363-4c63-4e13-8760-534011375158', \
|
12 |
# '2139381b-bfdd-4280-93c5-611a09d51d72', '40adbe9a-9f8f-44e3-aa41-851d6f918c1e', 'ebae5030-9d5e-40a5-9fb9-c0cf20d66030', \
|
13 |
# 'ef833df3-505e-4684-95d4-c9b64a52a8c8']
|
14 |
|
15 |
sqls = [] |
16 |
|
17 |
for index in range(len(drawing_uids)): |
18 |
drawing_uid = drawing_uids[index] |
19 |
|
20 |
sql = [] |
21 |
sql.append("delete from LINE_DATA_LIST where PNID_NO = '{}'".format(drawing_uid))
|
22 |
sql.append("delete from TitleBlockValues where Drawings_UID = '{}'".format(drawing_uid))
|
23 |
sql.append(f"delete from LineNoAttributes where Components_UID in " \
|
24 |
f"(select UID from Components where Drawings_UID='{drawing_uid}')")
|
25 |
sql.append(f"delete from Attributes where Components_UID in " \
|
26 |
f"(select UID from Components where Drawings_UID='{drawing_uid}')")
|
27 |
sql.append(f"delete from Associations where Components_UID in " \
|
28 |
f"(select UID from Components where Drawings_UID='{drawing_uid}')")
|
29 |
sql.append(f"delete from Points where Components_UID in " \
|
30 |
f"(select UID from Components where Drawings_UID='{drawing_uid}')")
|
31 |
sql.append(f"delete from PipeRunItems where PipeRuns_UID in " \
|
32 |
f"(select UID from PipeRuns where Drawings_UID='{drawing_uid}')")
|
33 |
sql.append(f"delete from PipeRuns where Drawings_UID='{drawing_uid}'")
|
34 |
sql.append("delete from Components where Drawings_UID='{}'".format(drawing_uid))
|
35 |
sql.append("delete from Stream_Line_List where Drawing_UID='{}'".format(drawing_uid))
|
36 |
sql.append("delete from Drawings where [UID]='{}'".format(drawing_uid))
|
37 |
|
38 |
sqls.append(";\n".join(sql))
|
39 |
|
40 |
#print(sqls)
|
41 |
fw = open(sqlPath, 'w', encoding='utf8') |
42 |
fw.write(";\n\n".join(sqls))
|
43 |
fw.close() |
44 |
|
45 |
|
46 |
if __name__ == '__main__': |
47 |
selection = input("select fuction(clear = 1) : ") |
48 |
if selection == '1': |
49 |
make_sql_delete_drawing_data() |