Cliente.py 1.39 KB
# -*- coding: <UTF8> -*-
import requests 
import json
import base64

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) 
	LEFT JOIN 
	res_partner AS cli ON comp.partner_id = cli.id
	LEFT JOIN
	res_country_state AS prov ON prov.id = cli.state_id
	LEFT JOIN
	res_country AS pais ON pais.id = cli.country_id
	LEFT JOIN
	koozo_dominios AS dom ON dom.id = comp.ain_dom_id
	LEFT JOIN
	koozo_localidad AS loc ON loc.id = cli.par_loc_id OR loc.id = pf.pfs_loc_id
) """

titulos = ["DOMINIO", "DATETIME", "FECHA", "CLENTE", "CALLE", "CALLE2", "LOCALIDAD", "PROBINCIA", "COD POSTAL", "PAIS", "DOMICILIO"]

Configuracion =  {"usuario": "administrador", "pass": "administrador", "puerto": 5432, "db": "isvareporte", "host": "127.0.0.1"}

parametros = {
    "DBconf": Configuracion,
    "Titulos": titulos,
    "select" : select
    }
var = json.dumps(parametros)

mpost = requests.post("http://127.0.0.1:11876/", data = var)
#mpost = requests.post("https://nextcloud.anacsoft.com/apirepote/", data = var)
r = mpost.json()
print(r["Nombre"])

f = open(r["Nombre"], 'w+b')
File = r["Archivo"].encode('ascii')
File = base64.b64decode(File)
f.write(File)
f.close()