hytos / minorTools / makeClearSql.py @ 11045d18
이력 | 보기 | 이력해설 | 다운로드 (2.61 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 = ['1e40e611-cd83-4c99-9711-b45321c3641e', '98240e9a-8ac9-4968-8203-7db2ace5023a']
|
7 |
|
8 |
|
9 |
drawing_uids = ['37f99bb8-9d4d-47f6-918a-4d0aadafba67', '38b003bc-3e46-45a8-8bdf-416110ccb084', \ |
10 |
'6fa42c26-b366-409c-b4b7-058d88c2abf0', '8331f923-57f6-4eaf-af8a-dcf13ea28286', '4b6672ad-40bc-4ef4-8f69-3fd28915ca9b', \ |
11 |
'd285f727-06c6-4406-ada3-8a923d065b04', 'd2881b09-8587-4e68-a26a-e8f629caa09a', 'd9cf86fb-d397-48c9-b164-d03deaafbf39', \ |
12 |
'3ae92a58-0fae-4c40-a92c-10431f1ca3b7', 'd212239f-4d47-4aeb-866c-2f4273d3b68f', '974ef07c-c285-4aaf-b363-61bdd34854fa', \ |
13 |
'92ddb680-1bd5-4772-bf7b-ea3a549692e1', 'f599f36d-0806-42e7-bd18-edfe430c2364', '95ab5d72-dbb5-4638-8431-82295d66cdd6'] |
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() |