개정판 7c2ecafc
issue #622: 저장 속도 개선
Change-Id: I2d181e3e07b8e0a6905bd8103f114d9796376218
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1984 | 1984 |
|
1985 | 1985 |
result = [] |
1986 | 1986 |
|
1987 |
conn = self.project.database.connect() |
|
1988 |
with conn: |
|
1987 |
with self.project.database.connect() as conn: |
|
1989 | 1988 |
try: |
1990 | 1989 |
# Get a cursor object |
1991 | 1990 |
cursor = conn.cursor() |
... | ... | |
3183 | 3182 |
drawing_name = self.activeDrawing.name |
3184 | 3183 |
drawing_uid = self.activeDrawing.UID |
3185 | 3184 |
|
3186 |
conn = self.project.database.connect() |
|
3187 |
with conn: |
|
3185 |
queries = {'first':[], 'second':[]} |
|
3186 |
for item in items: |
|
3187 |
if hasattr(item, 'toSql_return_separately'): |
|
3188 |
sql, sqlLater = item.toSql_return_separately() |
|
3189 |
queries['first'].append(sql) |
|
3190 |
queries['second'].append(sqlLater) |
|
3191 |
else: |
|
3192 |
queries['first'].append(item.toSql()) |
|
3193 |
|
|
3194 |
with self.project.database.connect() as conn: |
|
3188 | 3195 |
try: |
3189 | 3196 |
# Get a cursor object |
3190 | 3197 |
cursor = conn.cursor() |
3198 |
cursor.execute('begin') |
|
3191 | 3199 |
|
3192 | 3200 |
sql = "delete from LINE_DATA_LIST where PNID_NO = '{}'".format(drawing_name) |
3193 | 3201 |
cursor.execute(sql) |
... | ... | |
3228 | 3236 |
cursor.execute(sql) |
3229 | 3237 |
|
3230 | 3238 |
progress = 0 |
3231 |
sqlLters = [] |
|
3232 |
for item in items: |
|
3233 |
if hasattr(item, 'toSql_return_separately'): |
|
3234 |
sql, sqlLater = item.toSql_return_separately() |
|
3235 |
sqlLters.append(sqlLater) |
|
3236 |
else: |
|
3237 |
sql = item.toSql() |
|
3238 |
|
|
3239 |
length = len(queries['first']) + len(queries['second']) |
|
3240 |
for sql in queries['first']: |
|
3239 | 3241 |
if type(sql) is list: |
3240 | 3242 |
for item in sql: |
3241 | 3243 |
if item is not None and 2 == len(item): |
... | ... | |
3245 | 3247 |
cursor.executemany(self.project.database.to_sql(sql[0]), sql[1]) |
3246 | 3248 |
|
3247 | 3249 |
if show_progress: |
3248 |
show_progress.emit(int((progress / (len(items) + len(sqlLters)))*100))
|
|
3250 |
show_progress.emit(int((progress / length)*100))
|
|
3249 | 3251 |
progress += 1 |
3250 | 3252 |
|
3251 |
for sql in sqlLters:
|
|
3253 |
for sql in queries['second']:
|
|
3252 | 3254 |
if type(sql) is list: |
3253 | 3255 |
for item in sql: |
3254 | 3256 |
if item is not None and 2 == len(item): |
... | ... | |
3258 | 3260 |
cursor.executemany(self.project.database.to_sql(sql[0]), sql[1]) |
3259 | 3261 |
|
3260 | 3262 |
if show_progress: |
3261 |
show_progress.emit(int((progress / (len(items) + len(sqlLters)))*100))
|
|
3263 |
show_progress.emit(int((progress / length)*100))
|
|
3262 | 3264 |
progress += 1 |
3263 | 3265 |
|
3264 | 3266 |
if show_progress: |
3265 | 3267 |
show_progress.emit(99) |
3266 | 3268 |
|
3267 |
conn.commit()
|
|
3269 |
cursor.execute('commit')
|
|
3268 | 3270 |
# Catch the exception |
3269 | 3271 |
except Exception as ex: |
3270 | 3272 |
# Roll back any change if something goes wrong |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
128 | 128 |
pass |
129 | 129 |
|
130 | 130 |
def toSql(self): |
131 |
""" |
|
132 |
@brief convert to sql query |
|
133 |
@author humkyung |
|
134 |
@date 2018.11.07 |
|
135 |
""" |
|
131 |
"""convert to sql query""" |
|
136 | 132 |
pass |
137 | 133 |
|
138 | 134 |
def isOverlap(self, rect1, rect2): |
내보내기 Unified diff