Testeado el batch de indices en dev.
This commit is contained in:
parent
d71b69a611
commit
c234679a10
7 changed files with 170 additions and 23 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
6
db_layer/db_init_scripts/4_create_valores_indices.sql
Normal file
6
db_layer/db_init_scripts/4_create_valores_indices.sql
Normal 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 ;
|
||||
21
db_layer/indices_interface.py
Normal file
21
db_layer/indices_interface.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue