프로젝트

일반

사용자정보

개정판 49498c70

ID49498c70055cd1765814b4eb0a74c2d2f4b75cd9
상위 925e75b0
하위 9935088f

함의성이(가) 일년 이상 전에 추가함

add db clear function

Change-Id: I35af3ac361c97d0bb943c445d5ccaf07fbb7c509

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
4167 4167

  
4168 4168
        return result
4169 4169

  
4170
    def clearAllDrawingDataFromDatabase(self):
4171
        """ clear all drawing data from database """
4172

  
4173
        drawings = self.getDrawings()
4174

  
4175
        with self.project.database.connect() as conn:
4176
            try:
4177
                # Get a cursor object
4178
                cursor = conn.cursor()
4179

  
4180
                for drawing in drawings:
4181
                    sql = "delete from LINE_DATA_LIST where PNID_NO = '{}'".format(drawing.UID)
4182
                    cursor.execute(sql)
4183
                    sql = "delete from TitleBlockValues where Drawings_UID = '{}'".format(drawing.UID)
4184
                    cursor.execute(sql)
4185
                    sql = f"delete from LineNoAttributes where Components_UID in " \
4186
                                f"(select UID from Components where Drawings_UID='{drawing.UID}')"
4187
                    cursor.execute(sql)
4188
                    sql = f"delete from Attributes where Components_UID in " \
4189
                                f"(select UID from Components where Drawings_UID='{drawing.UID}')"
4190
                    cursor.execute(sql)
4191
                    sql = f"delete from Associations where Components_UID in " \
4192
                                f"(select UID from Components where Drawings_UID='{drawing.UID}')"
4193
                    cursor.execute(sql)
4194
                    sql = f"delete from Points where Components_UID in " \
4195
                                f"(select UID from Components where Drawings_UID='{drawing.UID}')"
4196
                    cursor.execute(sql)
4197
                    sql = f"delete from PipeRunItems where PipeRuns_UID in " \
4198
                                f"(select UID from PipeRuns where Drawings_UID='{drawing.UID}')"
4199
                    cursor.execute(sql)
4200
                    sql = f"delete from PipeRuns where Drawings_UID='{drawing.UID}'"
4201
                    cursor.execute(sql)
4202
                    sql = "delete from Components where Drawings_UID='{}'".format(drawing.UID)
4203
                    cursor.execute(sql)
4204
                    sql = "delete from Stream_Line_List where Drawing_UID='{}'".format(drawing.UID)
4205
                    cursor.execute(sql)
4206
                    sql = "delete from Views where Drawings_UID='{}'".format(drawing.UID)
4207
                    cursor.execute(sql)
4208
                    sql = "delete from Drawings where [UID]='{}'".format(drawing.UID)
4209
                    cursor.execute(sql)
4210

  
4211
                    if self.project.database.db_type == 'SQLite':
4212
                        cursor.execute('commit')
4213
                    else:
4214
                        conn.commit()
4215

  
4216
                # Catch the exception
4217
            except Exception as ex:
4218
                # Roll back any change if something goes wrong
4219
                conn.rollback()
4220

  
4221
                from App import App
4222
                message = 'error occurred({}\\n{}) in {}:{}'.format(repr(ex), sql,
4223
                                                                    sys.exc_info()[-1].tb_frame.f_code.co_filename,
4224
                                                                    sys.exc_info()[-1].tb_lineno)
4225
                App.mainWnd().addMessage.emit(MessageType.Error, message)
4226

  
4227

  
4170 4228
    def saveToDatabase(self, items, rect: QRectF, show_progress=None):
4171 4229
        """ save given items to database """
4172 4230
        import uuid

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)