Esempio n. 1
0
# ----------------------
server_ = 'MSSQL_DEV'
db_name = 'EJ_WRK_FACTORS3'
print('>>> Checking if DB: {} exists:'.format(db_name))
conn = connectDB(server_)
if not check_exist(conn, db_name):
    while True:
        input_ = input(
            '    Table does not exist! Proceed to create one?? (y/n)')
        if input_ in ['y', 'n']:
            break
        else:
            print('    Input should be y/n. Try Again.')
    if input_ == 'y':
        create_table(conn, db_name, up.typeStr, primary=up.primary)
    else:
        conn.close()
        exit()
else:
    print('    Exists. Checked.\n')
conn.close()


# ----------------------
# UPLOADING SCRIPT
def unloadedFactors_log(filename, StyleName, morethan_):
    today_ = dt.date.today().strftime('%Y%m%d')
    print('    !!! No data to update "{}"'.format(fctr))
    print('    !!! Current DB maxDate is "{}"'.format(morethan_))
    print('    !!! Leaving Log in "WARN_unloadedFactors_{}.log"'.format(
Esempio n. 2
0
from batch_utils.common import list2sqlstr, _conv2strCol, rm_backward, chunker
from batch_utils import WS_currVal

bkfil, rtvStart, seq_DT = batch_sequence('backfill', 'M')

Table = 'WSPITCmpIssFData'
Code = ['6751']
Item = '9802'  # beta
cal_dt_ = seq_DT.rename('marketdate')

S0 = pd.Series({'marketdate': 'datetime'})
primary = 'marketdate'
typeStr = create_typeStr(S0, primary=primary)

conn = connectDB(ODBC_NAME="MSSQL_QAD")
create_table(conn, '#Calendar', typeStr, primary=primary)
update_table(conn, '#Calendar', cal_dt_, typeStr, verbose=False)

Sql_S = """
Select convert(varchar(8),mm.marketdate,112) as marketdate, dt.Code,
        dt.Item, convert(varchar(8), dt.StartDate,112) as StartDate,
        convert(varchar(8), dt.EndDate,112) as EndDate, dt.Value_
    from #Calendar mm
    left outer join {} dt with (nolock)
    on mm.marketdate >= dt.StartDate
    and mm.marketdate <= isnull(dt.EndDate, dateadd(d,2,GETDATE()))
    where dt.Code in ({})
    and dt.Value_ <> -1e+38
    and not (dt.Value_ = 0  and dt.EndDate is NULL)
    and dt.Item='{}'
""".format(Table, list2sqlstr(Code), Item)