Testeado el batch de indices en dev.

This commit is contained in:
pablomartincalvo 2018-12-23 18:30:11 +01:00
parent d71b69a611
commit c234679a10
7 changed files with 170 additions and 23 deletions

View file

@ -111,7 +111,7 @@ class CapturasInterface:
WHERE (`t1`.`referencia` = `t2`.`referencia`)
)
)
AND (`t1`.`fecha_captura` BETWEEN %(start_date)S AND %(end_date)S)
AND (`t1`.`fecha_captura` BETWEEN %(start_date)s AND %(end_date)s)
)
"""
query_parameters = {'start_date': start_date.strftime('%Y-%m-%d 00:00:00'),

View file

@ -0,0 +1,6 @@
CREATE TABLE `valores_indices` (
`fecha_valor` datetime NOT NULL,
`nombre_indice` varchar(255) NOT NULL,
`valor_indice` double NOT NULL,
PRIMARY KEY (`fecha_valor`,`nombre_indice`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;

View file

@ -0,0 +1,21 @@
from core.mysql_wrapper import get_anunciosdb
class IndicesInterface:
def __init__(self):
self.anunciosdb = get_anunciosdb()
def write_index(self, index_data):
query_statement = """ REPLACE INTO valores_indices
(fecha_valor, nombre_indice, valor_indice)
VALUES
(%(date)s, %(name)s, %(value)s)
"""
query_parameters = index_data
self.anunciosdb.query(query_statement, query_parameters)
indices_interface = IndicesInterface()