|
|
|
|
|
|
|
|
if cursor.rowcount == 0: |
|
|
if cursor.rowcount == 0: |
|
|
sql_res.append({"content": "\nTotal: 0\n No record in the database!"}) |
|
|
sql_res.append({"content": "\nTotal: 0\n No record in the database!"}) |
|
|
break |
|
|
break |
|
|
single_res = pd.DataFrame([i for i in cursor.fetchmany(self._param.top_n)]) |
|
|
|
|
|
single_res.columns = [i[0] for i in cursor.description] |
|
|
|
|
|
|
|
|
if self._param.db_type == 'mssql': |
|
|
|
|
|
single_res = pd.DataFrame.from_records(cursor.fetchmany(self._param.top_n),columns = [desc[0] for desc in cursor.description]) |
|
|
|
|
|
else: |
|
|
|
|
|
single_res = pd.DataFrame([i for i in cursor.fetchmany(self._param.top_n)]) |
|
|
|
|
|
single_res.columns = [i[0] for i in cursor.description] |
|
|
sql_res.append({"content": "\nTotal: " + str(cursor.rowcount) + "\n" + single_res.to_markdown()}) |
|
|
sql_res.append({"content": "\nTotal: " + str(cursor.rowcount) + "\n" + single_res.to_markdown()}) |
|
|
break |
|
|
break |
|
|
except Exception as e: |
|
|
except Exception as e: |
|
|
|
|
|
|
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
def debug(self, **kwargs): |
|
|
def debug(self, **kwargs): |
|
|
return self._run([], **kwargs) |
|
|
|
|
|
|
|
|
return self._run([], **kwargs) |