Cliente.py
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- 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
) WHERE pf."tws_Tipo" = 'cent' AND pf.create_date >= '01/01/2019 12:00:00 AM' AND pf.create_date <= '01/02/2020 12:00:00 AM'"""
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("http://192.168.15.69:8080", 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()