Commit 49eb8a3f by Juan

psql pruebas

1 parent bddbb722
import xlsxwriter
import time
class Reporte():
COLUMNA = ("A", "B", "C", "E", "F", "G", "H", "I", "J", "K",
"L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "Y", "Z")
def __init__(self):
self.fecha = time.strftime("%y%m%d")
self.archivo = "tmp/reporte"+ self.fecha + ".xlsx"
self.QUERY = []
def NombreArchivo(self, nombre):
self.archivo = "tmp/"+ nombre + self.fecha + ".xlsx"
def __generarLibro__(self):
self.Libro = xlsxwriter.Workbook(self.archivo)
self.bold = self.Libro.add_format({'bold': True})
self.Hoja1 = self.Libro.add_worksheet("Totalizado")
def __escribir_linea__(self, datos, linea):
n = 0
for dato in datos:
celda = Reporte.COLUMNA[n] + linea
self.Hoja1.write(celda, str(dato))
n = n + 1
def __escribir_global(self):
n = 2
for query in self.QUERY:
self.__escribir_linea__(query, str(n))
n = n + 1
def ArmarLibro(self, estado="1"):
self.__generarLibro__()
self.__escribir_global()
self.fin()
return(self.archivo)
def fin(self):
self.Libro.close()
from Libmod.psql import BaseDatos from Libmod.psql import BaseDatos
from Libmod.reporte import Reporte
repo = Reporte()
db = BaseDatos() db = BaseDatos()
db.SELECT = """SELECT dom.name as dominio, pf.create_date, pf.pfs_fecha, cli.name, cli.street, cli.street2, loc.name AS localidad, prov.name AS provincia, cli.zip AS codigo_postal, pais.name AS pais, pf.domicilio AS domicilio_pf FROM db.SELECT = """SELECT dom.name as dominio, pf.create_date, pf.pfs_fecha, cli.name, cli.street, cli.street2, loc.name AS localidad, prov.name AS provincia, cli.zip AS codigo_postal, pais.name AS pais, pf.domicilio AS domicilio_pf FROM
( (
(koozo_planillafosa AS pf LEFT JOIN account_invoice AS comp ON pf.pfs_acc_inv = comp.id) (koozo_planillafosa AS pf LEFT JOIN account_invoice AS comp ON pf.pfs_acc_inv = comp.id)
...@@ -17,4 +19,7 @@ db.SELECT = """SELECT dom.name as dominio, pf.create_date, pf.pfs_fecha, cli.nam ...@@ -17,4 +19,7 @@ db.SELECT = """SELECT dom.name as dominio, pf.create_date, pf.pfs_fecha, cli.nam
) WHERE pf."tws_Tipo" = 'cent' AND pf.create_date >= '01/01/2019 12:00:00 AM' AND pf.create_date <= '01/02/2019 12:00:00 AM'""" ) WHERE pf."tws_Tipo" = 'cent' AND pf.create_date >= '01/01/2019 12:00:00 AM' AND pf.create_date <= '01/02/2019 12:00:00 AM'"""
db.Leer() db.Leer()
print(db.resultado)
\ No newline at end of file \ No newline at end of file
#query = db.resultado
repo.QUERY = db.resultado
repo.ArmarLibro()
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!