# -*- coding: utf-8 -*-
from sqlalchemy import create_engine
import pandas as pd
import sys


reload(sys)
sys.setdefaultencoding('utf8')

'''
1、问财务要量化派同资金方之间的打款流水转账记录
2、根据提供的数据录入到audit.fund_to_bank_2017,fund_to_lkb,lkb_to_fund 表中
3、2017.5月所有资金方都是直投模式，无资金方打款给量化派
'''
engine_audit = create_engine('mysql+mysqldb://yulong_rw:TouBStYwN8wkdxVt@172.16.3.201:3306/audit?charset=utf8', echo=True)

'量化派打款给资金方'
def lkb_to_fund():
    filename = u'E:/核对账单/还资金方/201705/现金贷5月付款.xlsx'
    df=pd.read_excel(filename)
    df=df.ix[df[u'收/付'] == u'付']
    df.rename(columns={u'日期':'transfer_time',u'请/交款人':'fund_corp',u'贷方':'transfer_amount',u'摘要':'remark'},inplace=True)
    df.transfer_time = pd.to_datetime(df.transfer_time).apply(lambda x:x.date())
    df=df[['transfer_time','fund_corp','transfer_amount','remark']]
    df['bank']=u'平安银行'
    df.to_sql(name='lkb_to_fund', con=engine_audit, if_exists='append', index=None)

#lkb_to_fund()