8000 Close DB connections · potchangelo/python-mysql-excel@2423d30 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2423d30

Browse files
committed
Close DB connections
1 parent bd1c92e commit 2423d30

File tree

8 files changed

+39
-7
lines changed

8 files changed

+39
-7
lines changed

scripts/export_data_01.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ def run():
3737
sheet.append(p)
3838

3939
# - Export ไฟล์ Excel
40-
workbook.save(filename="./files/exported_01.xlsx")
40+
workbook.save(filename="./files/exported_01.xlsx")
41+
42+
# ปิดการเชื่อมต่อ Database
43+
cursor.close()
44+
db.close()

scripts/export_data_02.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ def run():
3838
sheet.append(p)
3939

4040
# - Export ไฟล์ Excel
41-
workbook.save(filename="./files/exported_02.xlsx")
41+
workbook.save(filename="./files/exported_02.xlsx")
42+
43+
# ปิดการเชื่อมต่อ Database
44+
cursor.close()
45+
db.close()

scripts/export_data_03.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ def run():
4141
sheet.append(p_real)
4242

4343
# - Export ไฟล์ Excel
44-
workbook.save(filename="./files/exported_03.xlsx")
44+
workbook.save(filename="./files/exported_03.xlsx")
45+
46+
# ปิดการเชื่อมต่อ Database
47+
cursor.close()
48+
db.close()

scripts/export_data_04.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@ def run():
4444
sheet.append(p_real)
4545

4646
# - Export ไฟล์ Excel
47-
workbook.save(filename="./files/exported_04.xlsx")
47+
workbook.save(filename="./files/exported_04.xlsx")
48+
49+
# ปิดการเชื่อมต่อ Database
50+
cursor.close()
51+
db.close()

scripts/export_data_05.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ def run():
8282
cell.style = row_style
8383

8484
# - Export ไฟล์ Excel
85-
workbook.save(filename="./files/exported_05.xlsx")
85+
workbook.save(filename="./files/exported_05.xlsx")
86+
87+
# ปิดการเชื่อมต่อ Database
88+
cursor.close()
89+
db.close()

scripts/import_data_01.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ def run():
3838
db.commit()
3939

4040
# - สรุปจำนวนข้อมูลที่เพิ่มไป
41-
print('เพิ่มข้อมูลจำนวน ' + str(cursor.rowcount) + ' แถว')
41+
print('เพิ่มข้อมูลจำนวน ' + str(cursor.rowcount) + ' แถว')
42+
43+
# ปิดการเชื่อมต่อ Database
44+
cursor.close()
45+
db.close()

scripts/import_data_02.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ def run():
4343
db.commit()
4444

4545
# - สรุปจำนวนข้อมูลที่เพิ่มไป
46-
print('เพิ่มข้อมูลจำนวน ' + str(cursor.rowcount) + ' แถว')
46+
print('เพิ่มข้อมูลจำนวน ' + str(cursor.rowcount) + ' แถว')
47+
48+
# ปิดการเชื่อมต่อ Database
49+
cursor.close()
50+
db.close()

scripts/import_data_03.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ def run():
4747

4848
# - สรุปจำนวนข้อมูลที่เพิ่มไป
4949
print('เพิ่มข้อมูลจำนวน ' + str(cursor.rowcount) + ' แถว')
50+
51+
# ปิดการเชื่อมต่อ Database
52+
cursor.close()
53+
db.close()

0 commit comments

Comments
 (0)
0