Exemple #1
0
#!/usr/bin/env python3

import pandas as pd
import sys
import getopt
from progress.bar import Bar
from config import mysql_user, mysql_password
from config import mysql_host, mysql_database, mysql_port
from sqlalchemy import create_engine
from utils import STATES, CAPITALS, COLS_VICES_XY, COLS_VICES_XY_NEW
from utils import CAND_TABLE_NAME, CAND_TABLE_NAME_ID
from utils import tic, toc, write_to_csv

DATABASE = 'mysql+mysqlconnector://' + mysql_user() + ':' + mysql_password() + \
    '@' + mysql_host() + ':' + mysql_port() + '/' + mysql_database()


def main(argv):
    global STATES
    year, state, ext, shift = (None, None, None, None)
    usage = '05-cand-info-vices.py -y 2016 -s SC -t 1 or 2 -e data.csv'

    try:
        opts, _args = getopt.getopt(
            argv, 'hy:s:t:e:', ['year=', 'state=', 'shift=', 'ext='])
    except getopt.GetoptError:
        print(usage)
        sys.exit()
    for opt, arg in opts:
        if opt == '-h':
            print(usage)
Exemple #2
0
import time
import pandas as pd
from config import mysql_host, mysql_database, mysql_port
from config import mysql_user, mysql_password, mysql_raise_on_warnings

DATABASE = {
    'host': mysql_host(),
    'database': mysql_database(),
    'port': mysql_port(),
    'user': mysql_user(),
    'password': mysql_password(),
    'raise_on_warnings': mysql_raise_on_warnings()
}

CAND_TABLE_NAME = 'cand_info'
CAND_TABLE_NAME_ID = 'cand_info_id'

TIC_TIME_START = 0

STATES = [
    'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', 'MS',
    'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN', 'RS', 'RO', 'RR', 'SC',
    'SP', 'SE', 'TO'
]

CAPITALS = {
    'AC': 'RIO BRANCO',
    'AL': 'MACEIÓ',
    'AP': 'MACAPÁ',
    'AM': 'MANAUS',
    'BA': 'SALVADOR',