Files
ciec2026/ciec/procesos.py
2025-12-21 15:14:34 -06:00

44 lines
1.6 KiB
Python
Executable File

from django.db import transaction
from django.db import connection
from datetime import datetime, timedelta
#from explorer.models import Query
def dictfetchall(cursor):
desc = cursor.description
if desc:
return [
dict(zip([col[0] for col in desc],row))
for row in cursor.fetchall()
]
else:
return None
def execsql(consulta):
cursor = connection.cursor()
#print(consulta)
cursor.execute(consulta)
result_list = dictfetchall(cursor)
cursor.close()
return result_list
def styles_workbook(workbook):
#workbook = writer.book
#styles = []
style = {}
style['titulos'] = workbook.add_format({'bold': True, 'align': 'center', 'valign': 'vcenter'})
style['celdas'] = workbook.add_format({'align': 'center', 'valign': 'vcenter'})
style['bordes'] = workbook.add_format({'bottom': 1})
style['descripcion'] = workbook.add_format({'align': 'left', 'valign': 'vjustify'})
style['numeros'] = workbook.add_format({'num_format': '#,##0.00', 'valign': 'vcenter'})
style['fechas'] = workbook.add_format({'align': 'center', 'valign': 'vcenter', 'num_format' : 'dd/mmm/yyyy' })
style['cabecera'] = workbook.add_format({'bold': True, 'text_wrap': True, 'valign': 'top', 'align' : 'center', 'fg_color': '#D7E4BC', 'border': 1})
style['condicion1'] = workbook.add_format({'bold': True, 'bg_color': '#FFC7CE', 'font_color': '#9C0006'})
style['condicion2'] = workbook.add_format({'bold': True, 'bg_color': '#C6EFCE', 'font_color': '#006100'})
style['ocultar'] = workbook.add_format({'font_color': '#FFFFFF'})
#styles.append(style)
return style