예제 #1
0
@author: Mr6                                                                                                                    
"""                                                                                                                             
import mysql.connector                                                                                                          
import method
#datatype=0 按报告期 datatype=1 按年度 datatype=2 按季度                                                                 
                                                                                                                                
stockcode=''                                                                                                                 
                                                                                                                                f = open('d:\get_lrb.log', 'w')                                                                                                                                
                                                                                                                                
#数据库连接
conn = mysql.connector.connect(user='******', password='******', database='test')
cursor = conn.cursor()

codelist = method.get_StockCode(cursor,conn)
#获取主要指标表
for stockcode in codelist:
    
    dicts = method.get_data_main('0',stockcode[0])    
    dicts1 = method.get_data_main('1',stockcode[0])
    dicts2 = method.get_data_main('2',stockcode[0])
    if(dicts):
        method.insert_data('0',stockcode,dicts,'main_financial_indicator',cursor,conn,f)
    if(dicts1):
    method.insert_data('1',stockcode,dicts1,'main_financial_indicator',cursor,conn,f)
    if(dicts2):
    method.insert_data('2',stockcode,dicts2,'main_financial_indicator',cursor,conn,f)
   
cursor.close()
conn.close()

예제 #2
0
endDate2=''

f = open('d:\get_lrb.log', 'w')                                                                                                                                
#数据库连接
conn = mysql.connector.connect(user='******', password='******', database='test')
cursor = conn.cursor()

codelist = method.get_StockCode(cursor,conn)
#获取资产负债表
for stockcode in codelist:
    #获取报告期数据
    f.write("==============开始获取  %s 的报告期利润表数据==============\n" %stockcode[0])
    f.flush() 
    dicts = method.get_data_lrb(stockcode[1],'0','1','',stockcode[0],f)
    if(dicts):
        method.insert_data('0',stockcode[0],dicts,'lrb',cursor,conn,f)
        while(dicts and len(dicts)>5):        
            endDate = dicts[-2]['REPORTDATE']
            f.write("code=%s  endDate=%s \n" %(stockcode[0],endDate))
            f.flush()
            dicts = method.get_data_lrb(stockcode[1],'0','1',endDate,stockcode[0],f)
            method.insert_data('0',stockcode[0],dicts[1:6],'lrb',cursor,conn,f)
    #获取年度数据
    f.write("==============开始获取  %s 的年度利润表数据  ==============\n" %stockcode[0])
    f.flush() 
    dicts1 = method.get_data_lrb(stockcode[1],'1','1','',stockcode[0],f)
    if(dicts1):
        method.insert_data('1',stockcode[0],dicts1,'lrb',cursor,conn,f) 
        while(dicts1 and len(dicts1)>5):
            endDate1 = dicts1[-2]['REPORTDATE']
            f.write("code1=%s  endDate1=%s \n" %(stockcode[0],endDate1))
예제 #3
0
cursor = conn.cursor()

codelist = method.get_StockCode(cursor, conn)
#获取资产负债表
for stockcode in codelist:
    #获取报告期数据
    f.write("==============开始获取  %s 的报告期百分比报表数据==============\n" %
            stockcode[0])
    f.flush()
    zbdict = method.get_data_bfbbb_zb(stockcode[0], stockcode[1], '0', f)
    if (zbdict):
        method.insert_onedata('0', stockcode[0], zbdict, 'bfbbb_zb', cursor,
                              conn, f)
    dicts = method.get_data_bfbbb_lr(stockcode[0], stockcode[1], '0', f)
    if (dicts):
        method.insert_data('0', stockcode[0], dicts, 'bfbbb_lr', cursor, conn,
                           f)

    #获取年度数据
    f.write("==============开始获取  %s 的年度百分比报表数据  ==============\n" %
            stockcode[0])
    f.flush()
    zbdict1 = method.get_data_bfbbb_zb(stockcode[0], stockcode[1], '1', f)
    if (zbdict1):
        method.insert_onedata('1', stockcode[0], zbdict1, 'bfbbb_zb', cursor,
                              conn, f)
    dicts1 = method.get_data_bfbbb_lr(stockcode[0], stockcode[1], '1', f)
    if (dicts1):
        method.insert_data('1', stockcode[0], dicts1, 'bfbbb_lr', cursor, conn,
                           f)
    #获取季度数据
    f.write("==============开始获取  %s 的季度百分比报表数据  ==============\n" %