프로젝트

일반

사용자정보

통계
| 개정판:

hytos / minorTools / makeClearSql.py @ 7c7f8619

이력 | 보기 | 이력해설 | 다운로드 (4.25 KB)

1
def make_sql_delete_drawing_data():
2
    import os
3
    
4
    sqlPath = os.path.join('E:\Projects\DTIPID_GERRIT\minorTools', 'clear.txt')
5

    
6
    drawing_uids = ['1e40e611-cd83-4c99-9711-b45321c3641e', '98240e9a-8ac9-4968-8203-7db2ace5023a']
7

    
8
    '''
9
    drawing_uids = ['ca0423e7-bde1-4b64-9d4a-45afa09d2b19', 'cf1166cd-b027-4d5e-88b2-d817e8d9638f', \
10
                    'd17b490e-9c33-4451-a727-0cfc076ee8f3', 'd7dd4f37-db5f-433a-b76a-9843027f4307', 'dc4df203-9fd7-47c0-a1c7-704be8f68719', \
11
                    'ecbe6ada-dd70-419f-8bf1-0df8edb524f0', 'f1cdd4b3-d54a-48e8-9855-85cdf426142e', 'f52d3484-f6bc-4a4f-b8a8-04f867b4cbb6', \
12
                    'c78fb418-c005-424a-ace2-0d1f2ffc4bf4', 'baf31801-664a-495e-9980-f2dc12e15af1', 'b3a73579-9ae3-4898-9c9b-f95afbce9ee0', \
13
                    'b34ecc0e-b7b1-4adf-aade-dd45efca674d', 'b34195f8-9d82-47aa-9cb0-c36dc1663818', 'a9d23ee4-9ecc-45f5-b0bb-2dcda5c33073', \
14
                    'a778dcd1-9057-45ff-894e-3175cefe6d1a', 'a5d484fe-2ade-4e1c-9a9b-8dd006c88e47', 'a38c297a-63cf-4b8c-88d2-2f3d0e3b5688', \
15
                    '8559385b-2867-4e0f-a12d-790eaa825675', '84db639f-5d74-401f-b7b6-7a9cf21afbd6', '7e26f3de-a2b2-47cb-9d35-bbd8e2135766', \
16
                    '7d384f5e-78b5-47ac-8149-9133ff920a41', '7ab9dafc-a7cf-41ed-bbb2-b47d15f380ae', '70f7edd3-20ed-48f5-9582-b55ecc91a692', \
17
                    '69c83b39-506d-4374-a3c0-02325c7635fa', '67f11eb7-3a52-44c3-bf6c-fbf9bc5e67ca', '64024d94-6614-49fd-89c3-c01ac2fff4d1', \
18
                    '62ae882f-132e-46ef-b919-0b8b899b56ec', '621050f6-96d4-40b6-af05-375b8bd687a4', '6050692d-b161-438b-8e1b-7963f00c5867', \
19
                    '5f2e285e-063a-4559-8b48-6582f00d6a0c', '5ca8dabc-8915-471f-a7f7-8ba06448f1fa', '59509cac-3ae4-4fb5-a524-c64aa6d0f2d6', \
20
                    '57cf3bb6-bf4d-484c-877b-eff64528ff49', '56525817-8b31-4fad-9109-4ce479f98180', '509aaae4-f815-4d59-9987-bf717f38c481', \
21
                    '4b631ec9-3cd2-4aff-b08d-96ba094e0e8a', '4a10a4eb-9c55-4d80-b94d-704c21707ec1', '48275869-8499-4e81-aa13-f176c696d81b', \
22
                    '46737b5a-48c8-4341-b5a3-5ef4e1c9257d', '43e1415d-439e-4ba2-bcbd-43b50aae076a', '2bc0a497-3fcf-466e-91af-5cafe38b5456', \
23
                    '2592d47c-426c-45d1-9c5d-e97aafff8bff', '1ec4c0c1-5430-43d8-a6ae-e6d5603b31c5', '1bf84e1e-aa91-4f90-82f7-ae7d56fba9fd', \
24
                    '18fcfb0d-1529-4cdf-a94f-47edab607bc2', '12bb5341-2038-44e7-b8d7-1d55be426bb2', '10c7e8e1-dd25-47f2-b691-71192693a12d', \
25
                    '0a4f828f-68c1-486c-83b9-4be49a443135', '07a5abbd-88d5-460f-89bc-7bb7cedc9746', '0547c696-1963-44c2-9eba-5100297edd40', \
26
                    '046e4093-9d9c-49f2-bd7c-af9afedf34d3', '03347731-0f96-4be7-b4bd-223d70c67f75', '016da493-0e9d-42d3-b942-5a45cb36335e']
27
    '''
28
    sqls = []
29

    
30
    for index in range(len(drawing_uids)):
31
        drawing_uid = drawing_uids[index]
32
    
33
        sql = []
34
        #sql.append("delete from LINE_DATA_LIST where PNID_NO = '{}'".format(drawing_name))
35
        sql.append("delete from TitleBlockValues where Drawings_UID = '{}'".format(drawing_uid))
36
        sql.append(f"delete from LineNoAttributes where Components_UID in " \
37
                      f"(select UID from Components where Drawings_UID='{drawing_uid}')")
38
        sql.append(f"delete from Attributes where Components_UID in " \
39
                      f"(select UID from Components where Drawings_UID='{drawing_uid}')")
40
        sql.append(f"delete from Associations where Components_UID in " \
41
                      f"(select UID from Components where Drawings_UID='{drawing_uid}')")
42
        sql.append(f"delete from Points where Components_UID in " \
43
                      f"(select UID from Components where Drawings_UID='{drawing_uid}')")
44
        sql.append(f"delete from PipeRunItems where PipeRuns_UID in " \
45
                      f"(select UID from PipeRuns where Drawings_UID='{drawing_uid}')")
46
        sql.append(f"delete from PipeRuns where Drawings_UID='{drawing_uid}'")
47
        sql.append("delete from Components where Drawings_UID='{}'".format(drawing_uid))
48

    
49
        sqls.append("\n".join(sql))
50

    
51
    #print(sqls)
52
    fw = open(sqlPath, 'w', encoding='utf8')
53
    fw.write("\n\n".join(sqls))
54
    fw.close()
55

    
56

    
57
if __name__ == '__main__':
58
    selection = input("select fuction(clear = 1) : ")
59
    if selection == '1':
60
        make_sql_delete_drawing_data()
클립보드 이미지 추가 (최대 크기: 500 MB)