コード例 #1
0
ファイル: user_module.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description="Merge multiple csv files into excel file, each csv")
    parser.add_argument("--server", default=r"MEL-TST-001\WEBSQL", help="Database Server")
    parser.add_argument("--database", default=r"Lonsec", help="Database Name")
    parser.add_argument("-v", "--verbose", action="count", default=0)
    parser.add_argument("-i", "--input", help="An excel file (normally from Jen Lee)", required=True)
    parser.add_argument("--sheet", help="Sheet Name or Sheet Index", required=True)
    parser.add_argument("--dry-run", action="store_true")

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = (
        r"Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};"
        "Trusted_Connection=yes;".format(server=a.server, database=a.database)
    )

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    upload_benchmark(db, a.input, a.sheet)

    if not a.dry_run:
        logger.info("Commit changes")
        db.commit()
    else:
        logger.info("All changes did not commit")
コード例 #2
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    double_check(db)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #3
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--recommendation', help='Recommendation. Check tblRecommendation for Name', required=True, default='Ceased Coverage')
    parser.add_argument('--investment-type-id', help='Investment Type ID. Default: 2 (Direct Equity)', required=True, type=int, default='2')
    parser.add_argument('--approved-by', help='Approved By', required=True)
    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')
    parser.add_argument('--investment-code', help='Investment Code aka Stock Code', required=True)


    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    logger.info(delists(db, a.investment_code, a.recommendation, a.investment_type_id, a.approved_by))

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #4
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--benchmark-name', help='Benchmark Name', required=True)
    parser.add_argument('--weight', help='Benchmark Weight ', required=True, nargs='+')
    parser.add_argument('--dry-run', help='Run without commit changes', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True
    logger.info(a)
    add(db, a.benchmark_name, a.weight)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #5
0
ファイル: stock_check.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-o', '--output', required=True, type=argparse.FileType('w'), help='Output file')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--dry-run', help='won\'t commit any changes', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    check_stock(db, a.output)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #6
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i', '--input', help='An excel file (normally from Jen Lee)', required=True)
    parser.add_argument('-o', '--output', help='CSV otuput file', type=argparse.FileType('w'), required=True)
    parser.add_argument('--sheet', help='Sheet Name or Sheet Index', required=True)
    parser.add_argument('--data-provider', help='ETF: 4, Lonsec: 1, more at tblDataProvider', default=3, required=True)
    parser.add_argument('--dry-run', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    extract(db, a.input, a.sheet, a.data_provider, a.output)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #7
0
ファイル: stock_delist.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--investment-status-id', help='Investment Status ID. Default: 3 (closed)', type=int, default=3)
    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')

    group = parser.add_mutually_exclusive_group()
    group.add_argument('--investment-code', help='Investment Code aka Stock Code')
    group.add_argument('--investment-id', help='Investment ID aka Stock ID')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    logger.info(delists(db, a.investment_id, a.investment_code, a.investment_status_id))

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #8
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i', '--input', help='An excel file (normally from Jen Lee)', required=True)
    parser.add_argument('--top10', help='Top 10 sheet name', required=True)
    parser.add_argument('--cost', help='Cost sheet name', required=True)
    parser.add_argument('--data-provider', help='ETF: 4, Lonsec: 1, more at tblDataProvider', default=6, required=True)
    parser.add_argument('--dry-run', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    logger.info('LOADING TOP 10')
    upload_top10(db, a.input, a.top10, a.data_provider)
    logger.info('*'*40)
    logger.info('LOADING COST')
    upload_cost(db, a.input, a.cost)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #9
0
ファイル: viewpoint.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--report-type', help='Fund or Stock'
                        , choices=['fundreport', 'investmentreport']
                        , required=True)
    parser.add_argument('--from-report-id', help='From report id', type=int)
    parser.add_argument('--to-report-id', help='To report id', type=int)
    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    add(db, a.from_report_id, a.to_report_id, a.report_type)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #10
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--client-id', help='Lonsec Client ID', type=int, required=True)
    parser.add_argument('--lonsec-contact-id', help='Lonsec Client ID', type=int)
    parser.add_argument('--domain-login', help='Domain Login MELBOURNE\\xxx', required=True)

    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    add(db, a.client_id, a.domain_login, a.lonsec_contact_id)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #11
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i', '--input', help='An excel file (normally from Jen Lee)', required=True)
    parser.add_argument('--upload-type', help='Investment Growth or Benchmark Growth'
                        , choices=['benchmark', 'investment']
                        , required=True)
    parser.add_argument('--sheet', help='Sheet Name or Sheet Index', required=True)
    parser.add_argument('--data-provider', help='ETF: 4, Lonsec: 1, more at tblDataProvider', default=8, required=True)
    parser.add_argument('--dry-run', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    if a.upload_type == 'benchmark':
        upload_benchmark(db, a.input, a.sheet, a.data_provider)
    else:
        upload_investment(db, a.input, a.sheet, a.data_provider)
    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #12
0
def consoleUI():
    parser = argparse.ArgumentParser(
        description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server',
                        default=r'MEL-TST-001\WEBSQL',
                        help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i',
                        '--input',
                        help='An excel file (normally from Jen Lee)',
                        required=True)
    parser.add_argument('--sheet',
                        help='Sheet Name or Sheet Index',
                        required=True)
    parser.add_argument('--data-provider',
                        help='ETF: 4, Lonsec: 1, more at tblDataProvider',
                        default=4,
                        required=True)
    parser.add_argument('--dry-run', action='store_true')
    parser.add_argument('--with-global',
                        help='Use this toggle if ETF file is global',
                        action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    tt_name = upload(db, a.input, a.sheet, a.data_provider)
    if a.with_global:
        logger.info('{0}{1}{0}'.format(
            '*' * 10, 'NOW LOAD to ExternalData.dbo.tblGrowthSeries FOR .arc'))
        upload_global(db, tt_name, a.data_provider)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #13
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i', '--input', help='An excel file (normally from Jen Lee)', required=True)
    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    process(db, a.input, a.dry_run)
コード例 #14
0
ファイル: etf_rec.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description="Merge multiple csv files into excel file, each csv")
    parser.add_argument("--server", default=r"MEL-TST-001\WEBSQL", help="Database Server")
    parser.add_argument("--database", default=r"Lonsec", help="Database Name")
    parser.add_argument("-i", "--input", help=r"ETF Stock list", required=True, type=argparse.FileType("r"))
    parser.add_argument("-o", "--output", help=r"CSV Output file", required=True, type=argparse.FileType("w"))
    parser.add_argument("-v", "--verbose", action="count", default=0)
    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = (
        r"Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};"
        "Trusted_Connection=yes;".format(server=a.server, database=a.database)
    )

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    get_recommendation(db, a.input, a.output)
コード例 #15
0
ファイル: etf_upload.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i', '--input', help='An excel file from James Chang)', required=True)
    parser.add_argument('--upload-type', help='Investment Growth or Benchmark Growth'
                        , choices=['benchmark', 'investment']
                        , required=True)
    parser.add_argument('--enable-not-found-is-ok', action='store_true')
    parser.add_argument('--sheet', help='Sheet Name or Sheet Index', required=True)
    parser.add_argument('--data-provider', help='ETF: 4, Lonsec: 1, more at tblDataProvider', default=4, required=True)
    parser.add_argument('--use-tblInvestmentCode', action='store_true')
    parser.add_argument('--dry-run', action='store_true')
    parser.add_argument('--with-global', help='Use this toggle if ETF file is global', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    tt_name = upload(db, a.input, a.sheet, a.data_provider, a.upload_type, a.enable_not_found_is_ok)
    if a.with_global:
        logger.info('{0}{1}{0}'.format('*'*10, 'NOW LOAD to ExternalData.dbo.tblGrowthSeries FOR .arc'))
        upload_global(db, tt_name, a.data_provider)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #16
0
def consoleUI():
    parser = argparse.ArgumentParser(description="Merge multiple csv files into excel file, each csv")
    parser.add_argument("--server", default=r"MEL-TST-001\WEBSQL", help="Database Server")
    parser.add_argument("--database", default=r"Lonsec", help="Database Name")
    parser.add_argument("-v", "--verbose", action="count", default=0)
    parser.add_argument("-i", "--input", help="An excel file (normally from Jen Lee)", required=True)
    parser.add_argument("--top10", help="Top 10 sheet name", required=True)
    parser.add_argument("--cost", help="Cost sheet name", required=True)
    parser.add_argument("--data-provider", help="ETF: 4, Lonsec: 1, more at tblDataProvider", default=6, required=True)
    parser.add_argument("--dry-run", action="store_true")

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = (
        r"Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};"
        "Trusted_Connection=yes;".format(server=a.server, database=a.database)
    )

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    logger.info("LOADING TOP 10")
    upload_top10(db, a.input, a.top10, a.data_provider)
    logger.info("*" * 40)
    logger.info("LOADING COST")
    upload_cost(db, a.input, a.cost)

    if not a.dry_run:
        logger.info("Commit changes")
        db.commit()
    else:
        logger.info("All changes did not commit")
コード例 #17
0
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('-i', '--input', help='An excel file (normally from Jen Lee)', required=True)
    parser.add_argument('--upload-type', help='Investment Growth or Benchmark Growth'
                        , choices=['etf', 'hybrids', 'model', 'ubs']
                        , required=True)
    parser.add_argument('--sheet', help='Sheet Name or Sheet Index', required=True)
    parser.add_argument('--data-provider', help='ETF: 4, Lonsec: 1, more at tblDataProvider', default=8, required=True, type=int)
    parser.add_argument('--dry-run', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string)

    if a.verbose > 1:
        db.debug = True

    if (a.upload_type in ['ubs', 'model']) and a.data_provider != 7:
        raise Exception('{} should have data provider 7 not {}'.format(a.upload_type, a.data_provider))

    upload(db, a.input, a.sheet, a.data_provider, a.upload_type)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #18
0
ファイル: stock_add.py プロジェクト: lslacker/custom-tools
def consoleUI():
    parser = argparse.ArgumentParser(description='Merge multiple csv files into excel file, each csv')
    parser.add_argument('--server', default=r'MEL-TST-001\WEBSQL', help='Database Server')
    parser.add_argument('--database', default=r'Lonsec', help='Database Name')
    parser.add_argument('-v', '--verbose', action='count', default=0)
    parser.add_argument('--stock-code', help='Stock Code', required=True)
    parser.add_argument('--force-new-stock', help='Force New Stock Code', type=int)
    parser.add_argument('--stock-name', help='Stock Name', required=True)
    parser.add_argument('--exchange-name', help='Exchange Name', required=True)
    parser.add_argument('--sector', help='Sector Name', required=True)
    parser.add_argument('--investment-id', help='Existing investment id (if any)', type=int)
    parser.add_argument('--investment-type-id', help='Sector Name', type=int, required=True)
    parser.add_argument('--show-on-web', help='Show On Web', type=int, default=1)
    parser.add_argument('--investment-status-id', help='Investment Status ID', type=int, default=1)
    parser.add_argument('--dry-run', help='An excel file (normally from Jen Lee)', action='store_true')

    a = parser.parse_args()

    if a.verbose > 1:
        logging.basicConfig(level=logging.INFO)

    connection_string1 = r'Driver={{SQL Server Native Client 11.0}};Server={server};Database={database};' \
                         'Trusted_Connection=yes;'.format(server=a.server, database=a.database)

    db = DB.from_connection_string(connection_string1)
    if a.verbose > 1:
        db.debug = True

    add(db, a.stock_code, a.stock_name, a.exchange_name, a.sector
        , a.investment_type_id, a.show_on_web, a.investment_status_id, a.investment_id, a.force_new_stock)

    if not a.dry_run:
        logger.info('Commit changes')
        db.commit()
    else:
        logger.info('All changes did not commit')
コード例 #19
0
ファイル: user_extract.py プロジェクト: lslacker/custom-tools
def write_data(output, data, header=None):
    with open(output, 'w') as f:
        csvwriter = csv.writer(f, lineterminator='\n')
        if header:
            csvwriter.writerow(header.split(','))
        csvwriter.writerows(data)

if __name__ == '__main__':
    connection_string1 = r'Driver={SQL Server Native Client 11.0};Server=mel-sql-002\WEBSQL;Database=LonsecLogin;' \
                         'Trusted_Connection=yes;'
    irate_connection_string = r'Driver={SQL Server Native Client 11.0};Server=mel-sql-006;Database=iRate;' \
                         'Trusted_Connection=yes;'
    octopus_connection_string = r'Driver={SQL Server Native Client 11.0};Server=mel-sql-001;Database=BackOffice;' \
                         'Trusted_Connection=yes;'
    db = DB.from_connection_string(connection_string1)
    irate_db = DB.from_connection_string(irate_connection_string)
    octopus_db = DB.from_connection_string(octopus_connection_string)

    logging.basicConfig(level=logging.DEBUG)

    # root_client_id = 47475  # IOOF Group
    # root_client_id = 13693  # RSM Bird Cameron
    #root_client_id = 43966  # Semaphore Private
    #root_client_id = 54528  # AMP
    root_client_id = 35014  # Unisuper

    clientids = get_childrens(db, root_client_id)

    exclude_financial_advisor = False
コード例 #20
0
def before_request():
    g.db = DB.from_connection_string(app.config['CONNECTION_STRINGS'])
コード例 #21
0
ファイル: app.py プロジェクト: lslacker/dblookup
def before_request():
    g.db = DB.from_connection_string(app.config['CONNECTION_STRINGS'])
コード例 #22
0
        '''.format(listid=listid)

    def replace_with_parent(row, parent):
        row[0] = parent
        return row

    rows = db.get_data(qry_get_investment_name())

    header = ['Portfolio', 'Strategy', 'Security Code', 'Exchange', 'Security Name', 'Weight', 'Effective Date']
    report_data = []
    for row in rows:
        listid, listname = row
        logger.info('Processing {} - {}'.format(listname, listid))
        data = db.get_data(qry_get_investment_list_benchmark_weight_details(listid))

        data = [replace_with_parent(row, listname) for row in data if row.Strategy]  # don't count first row
        report_data += data

    helper.write_data(output, report_data, header)

if __name__ == '__main__':
    connection_string1 = r'Driver={SQL Server Native Client 11.0};Server=mel-sql-002\WEBSQL;Database=Lonsec;' \
                         'Trusted_Connection=yes;'
    db = DB.from_connection_string(connection_string1)
    logging.basicConfig(level=logging.DEBUG)
    # output = r'C:\Users\Lmai\Documents\Workspaces\ir\ir-1191_unisuper-to-irate\\model_portfolio_extract.csv'
    # extract_modelportfolio(db, output)

    output = r'C:\Users\Lmai\Documents\Workspaces\ir\ir-1177_ldm-pe-model-benchmark-extract\benchmark_portfolio_extract.csv'
    extract_benchmarkportfolio(db, output)