Beispiel #1
0
def main():
    """Program takes at least one argument"""
    env = sys.argv[1]
    db_details = DB_DETAILS[env]
    tables = get_tables('table_list')
    for table in tables['table_name']:
        print(table)
Beispiel #2
0
def main():
    """The usage is :- python app.py env table_list """
    print("The parameters are:", sys.argv)
    env = sys.argv[1]
    a_tables = sys.argv[2]
    logger.add("logs/data-copier.info",
               rotation="1 KB",
               retention="10 days",
               level="INFO")
    logger.add("logs/data-copier.err",
               rotation="1 KB",
               retention="10 days",
               level="ERROR")

    db_details = load_db_details(env)
    print(db_details)
    logger.debug(db_details)
    tables = get_tables('table_list', a_tables)
    print(tables)
    logger.debug(tables)

    for table_name in tables['table_name']:
        logger.info(f'reading data for {table_name}')
        data, column_names = read_table(db_details, table_name)
        logger.debug(f'Data is: {data}')
        logger.debug(f"Column names are:{column_names}")
        logger.info(f'loading data for {table_name}')
        load_table(db_details, data, column_names, table_name)
def main():
    """PROGRAM TAKES ATLEAST ONE ARGUMENT"""
    env = sys.argv[1]
    db_details = DB_DETAILS[env]
    tables=get_tables('table_list.txt')
    for table in tables['table_name']:
        print(table)
Beispiel #4
0
def main():
    """Program takes at least one argument"""
    env = sys.argv[1]
    db_details = load_db_details(env)
    tables = get_tables('table_list')
    for table_name in tables['table_name']:
        print(f'reading data for {table_name}')
        data, column_names = read_table(db_details, table_name)
        print(f'loading data for {table_name}')
        load_table(db_details, data, column_names, table_name)
Beispiel #5
0
def main():
    env = sys.argv[1]
    a_tables = sys.argv[2]
    db_details = load_db_details(env)
    tables = get_tables('table_list', a_tables)
    for table in tables['table_name']:
        data, column_names = read_table(db_details, table)
        #test = build_insert_query(table, column_names)
        load_table(db_details, data, column_names, table)
        print(f'Successfully completed process for {table}')
Beispiel #6
0
def main():
    env = sys.argv[1]
    db_details = load_db_details(env)
    # print(db_details)
    tables = get_tables('tables_list.txt')
    # for idx,table in tables.iterrows():
    #    print (table)
    for table_name in tables['table_name']:
        print(f'reading data for {table_name}')
        data, column_names = read_table(db_details, table_name)
        print(f'loading data for {table_name}')
Beispiel #7
0
def main():
    env = sys.argv[1]
    db_details = load_db_details(env)
    print(db_details)
    tables = get_tables('table_list')
    db_details = DB_DETAILS[env]
    for table in tables['table_name']:
        print(f'Reading data from {table}')
        data, columns = read_table(db_details, table)
        print(data)
        print(f'Loading data into {table}')
        load_table(db_details, table, columns, data)
Beispiel #8
0
def main():
    if len(sys.argv) < 2:
        print("Usage: python <filename> <env>")
    env = sys.argv[1]
    db_details = DB_DETAILS[env]
    tables = get_tables('table_list.txt')
    for table in tables['table_name']:
        print(f'Reading data for table {table}')
        data, column_names = read_table(db_details, table)
        print(data)
        print(column_names)
        print(f'Loading data for table {table}')
Beispiel #9
0
def main():
    """Program takes at least one argument"""
    env = sys.argv[1]
    db_details = load_db_details(env)
    tables = get_tables('table_list')
    print("These are the tables to be loaded", tables)

    for table_name in tables['table_name']:
        print('Reading data for {}'.format(table_name))
        data, column_names = read_table(db_details, table_name)
        # print(column_names)
        print('Loading data for {}'.format(table_name))
        load_table(db_details, data, column_names, table_name)
def main():
    """ this takes atleast one argiument"""

    env = sys.argv[1]
    db_details = DB_DETAILS[env]
    tables = get_tables('table_list')
    print(tables)
    for table in tables['table_name']:
        print(table)
        data, column_names = read_table(db_details, table, limit=10)

        print(data)
        print(column_names)
        load_table(db_details, data, column_names, table)
Beispiel #11
0
def main():
    """Program takes at least one arguments"""

    db_details = load_db_details(env)
    tables = get_tables(path='src/main/python/table_list.csv',
                        table_list='all')
    for table in tables['table_name']:
        table_n = table
    # reading the data from mysql
    data, columns = read_table(db_details,
                               DB_USER=DB_USER_MYSQL,
                               DB_PASS=DB_PASS_MYSQL,
                               table_name=table_n)

    # loading data to postgres
    load_table(db_details=db_details,
               DB_USER=DB_USER_POSTGRES,
               DB_PASS=DB_PASS_POSTGRES,
               data=data,
               column_names=columns,
               table_name=table_n)
Beispiel #12
0
def main():
    tables = get_tables('Table_list')
Beispiel #13
0
import sys
from config import DB_DETAILS

<<<<<<< HEAD
=======
from util import get_tables

>>>>>>> Added to read table list that needs to be loaded from a file

def main():
    """Program take atleast one argument"""
    env = sys.argv[1]
    db_details = DB_DETAILS[env]
<<<<<<< HEAD
    print(db_details)
=======
    tables = get_tables('table_list')
    for table in tables['table_name']:
        print(table)
>>>>>>> Added to read table list that needs to be loaded from a file


if __name__=='__main__':
    main()