diff --git a/AppCode/MatCreditHandler.py b/AppCode/MatCreditHandler.py
index 892ef12..167163c 100644
--- a/AppCode/MatCreditHandler.py
+++ b/AppCode/MatCreditHandler.py
@@ -6,30 +6,24 @@ import mysql.connector
class MatCreditHandler:
def __init__(self):
- db = DBConfig()
- self.conn = db.get_db_connection()
+ # db = DBConfig()
+ self.conn = DBConfig.get_db_connection()
self.cursor = self.conn.cursor(dictionary=True)
- @staticmethod
- def fetch_all():
- conn = DBConfig.get_db_connection()
- cur = conn.cursor(dictionary=True)
-
+ # get all Mat credit data
+ def fetch_all(self):
try:
- # Stored Procedure returns TWO result sets
- cur.callproc("GetMatCedit")
-
- result_sets = cur.stored_results()
-
- mat_rows = next(result_sets).fetchall()
- utilization_rows = next(result_sets).fetchall()
-
- return mat_rows, utilization_rows
+ self.cursor.callproc("GetMatCedit")
+ result_sets = self.cursor.stored_results()
+ mat_rows = next(result_sets).fetchall()
+ utilization_rows = next(result_sets).fetchall()
+ return mat_rows, utilization_rows
finally:
- cur.close()
- conn.close()
+ self.cursor.close()
+ self.cursor.close()
+ # Save Mat credit data single row
@staticmethod
def save_single(data):
conn = DBConfig.get_db_connection()
@@ -81,6 +75,7 @@ class MatCreditHandler:
conn.close()
+ # save all Mat credit data
@staticmethod
def save_bulk(rows):
conn = DBConfig.get_db_connection()
@@ -120,4 +115,9 @@ class MatCreditHandler:
finally:
cur.close()
- conn.close()
\ No newline at end of file
+ conn.close()
+
+ # CLOSE CONNECTION
+ def close(self):
+ self.cursor.close()
+ self.conn.close()
diff --git a/main.py b/main.py
index 85df8a3..5985e0b 100644
--- a/main.py
+++ b/main.py
@@ -452,8 +452,8 @@ def check_year():
def mat_credit():
mat= MatCreditHandler()
-
mat_rows, utilization_rows = mat.fetch_all()
+ mat.close()
utilization_map = {}
all_years = set()
@@ -492,7 +492,6 @@ def save_mat_all():
return jsonify({"error": str(e)}), 500
-
# run
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5003, debug=True)
\ No newline at end of file
diff --git a/templates/add_ao.html b/templates/add_ao.html
index cc71b75..d72d16b 100644
--- a/templates/add_ao.html
+++ b/templates/add_ao.html
@@ -169,7 +169,6 @@
{% block extra_js %}
-
{% endblock %}
diff --git a/templates/add_cit.html b/templates/add_cit.html
index 832fd5d..aa77ac8 100644
--- a/templates/add_cit.html
+++ b/templates/add_cit.html
@@ -168,7 +168,6 @@
{% endblock %}
{% block extra_js %}
-
{% endblock %}
\ No newline at end of file
diff --git a/templates/add_itat.html b/templates/add_itat.html
index 0fe26ec..c345de5 100644
--- a/templates/add_itat.html
+++ b/templates/add_itat.html
@@ -171,7 +171,6 @@
{% endblock %}
{% block extra_js %}
-
{% endblock %}
diff --git a/templates/ao_reports.html b/templates/ao_reports.html
index 8b23b5f..4f3b40e 100644
--- a/templates/ao_reports.html
+++ b/templates/ao_reports.html
@@ -31,11 +31,5 @@
-{% block scripts %}
-
-
-{% endblock %}
-{% block extra_js %}
-{% endblock %}
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
index b894a44..b1eff67 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -27,31 +27,37 @@
Dashboard
-
+