Ejemplo n.º 1
0
    def __init__(self, conn=config.MYSQL_DATABASE_CONN):
        """Constructor method

        Keyword Arguments:
            conn {dict} -- A dict containing the database connection info (default: {config.MYSQL_DATABASE_CONN})
        """

        self.conn = conn
        self.logger = log.getLogger()
        _url = str(url.URL(**conn)) + "?charset=utf8"
        self.engine = create_engine(url.URL(**conn))
        self.query = None
        if self.logger.isEnabledFor(logging.DEBUG):
            listen(self.engine, "do_execute", self.__receive_do_execute)
Ejemplo n.º 2
0
import os
import pandas as pd
from lib_formatter_logger import log
from common.dao import querys
from config import LOG_NAME

CITIES_CSV = os.getcwd() + '/csv/climatempo_all_cities.csv'
logger = log.getLogger(LOG_NAME)


def import_cities():
    '''

    '''
    brasil = 1
    states = querys.get_all_regions(brasil)
    cities = pd.read_csv(CITIES_CSV,
                         sep=',',
                         header=0,
                         names=['state_code', 'city_name'])

    logger.info('registering all cities...')
    for state in states:
        for idx, city in cities.iterrows():
            if state['code'] == city.state_code:
                parameters = dict()
                parameters['name'] = city.city_name
                parameters['region_id'] = state['id']
                querys.create_locality(parameters)

Ejemplo n.º 3
0
from lib_formatter_logger import log
from lib_formatter_logger.utils import config_validator

logger = log.getLogger()

variables = [
    {
        "name": "MYSQL_DATABASE_SERVER",
        "required": True
    },
    {
        "name": "MYSQL_DATABASE_PORT",
        "default": 3306,
        "type": "int"
    },
    {
        "name": "MYSQL_DATABASE_USERNAME",
        "required": True
    },
    {
        "name": "MYSQL_DATABASE_PASSWORD",
        "required": True
    },
    {
        "name": "MYSQL_DATABASE_DATABASE",
        "required": True
    },
]

try:
    (  # pylint: disable=E0632
Ejemplo n.º 4
0
from datetime import datetime
from common.dao import querys
from common.datasource import connection
from common import util
from datetime import datetime
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup as bs
from lib_formatter_logger import log

logger = log.getLogger('tempnow')

DRIVE_CHROME = os.getcwd() + '/drives/chromedriver'
URL = 'https://www.tempoagora.com.br'
URL_STATE = f'{URL}/previsao-do-tempo'


def mount_links():
    '''

    '''
    links = list()
    brasil = 1
    count = 0

    for state in querys.get_all_regions(brasil):