optimize and add new service of get report and download report.
This commit is contained in:
30
services/Generalservice.py
Normal file
30
services/Generalservice.py
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
|
||||
class GeneralUse:
|
||||
data=[]
|
||||
|
||||
@staticmethod
|
||||
def execute_sp(cursor, proc_name, params=[], fetch_one=False):
|
||||
cursor.callproc(proc_name, params)
|
||||
return (
|
||||
GeneralUse.fetch_one_result(cursor)
|
||||
if fetch_one else
|
||||
GeneralUse.fetch_all_results(cursor)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def fetch_all_results(cursor):
|
||||
data = []
|
||||
for result in cursor.stored_results():
|
||||
data = result.fetchall()
|
||||
return data
|
||||
|
||||
|
||||
@staticmethod
|
||||
def fetch_one_result(cursor):
|
||||
data = None
|
||||
for result in cursor.stored_results():
|
||||
data = result.fetchone()
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user