当前位置: 首页>>代码示例>>Python>>正文


Python DataBase.connClose方法代码示例

本文整理汇总了Python中DataBase.connClose方法的典型用法代码示例。如果您正苦于以下问题:Python DataBase.connClose方法的具体用法?Python DataBase.connClose怎么用?Python DataBase.connClose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataBase的用法示例。


在下文中一共展示了DataBase.connClose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_report_price

# 需要导入模块: import DataBase [as 别名]
# 或者: from DataBase import connClose [as 别名]
def show_report_price(code,startdate):
    df = ts.get_hist_data(code, start=startdate)
    df1 = df[::-1]
    highdate=''
    highprice=0
    lowdate=startdate
    lowprice=1000
    i = 0
    for each in df1.index:
        if df1['close'].iloc[i] > highprice:
            highprice = df1['close'].iloc[i]
            highdate = each
        i=i+1
    i = 0
    for each in df1.index:
        if each < highdate:
            if df1['close'].iloc[i] < lowprice:
                lowprice = df1['close'].iloc[i]
                lowdate = each
        i = i+1
    print highdate, highprice
    print lowdate, lowprice
    print (highprice-lowprice)/lowprice
    engine = create_engine("mssql+pyodbc://sa:[email protected]")
    conn, cur = db.connDB()
    cur = db.exeQuery(cur,"select * from tb_report where code = '%s' and reportdate <= '%s' and reportdate >= '%s' order by reportdate" % (code,highdate,lowdate))
    all = cur.fetchall()
    db.connClose(conn,cur)
    print len(all)
开发者ID:cawind2,项目名称:TestConda32,代码行数:31,代码来源:DataModel.py

示例2: show_report

# 需要导入模块: import DataBase [as 别名]
# 或者: from DataBase import connClose [as 别名]
def show_report(code, startdate):
    df = ts.get_hist_data(code, start=startdate)
    df1 = df[::-1]
    x = df1.index
    xlist = x.tolist()
    y1 = df1['close']
    ylist1 = y1.tolist()
    engine = create_engine("mssql+pyodbc://sa:[email protected]")
    conn, cur = db.connDB()
    cur = db.exeQuery(cur,"select * from tb_report where code = '%s' and reportdate > '%s' order by reportdate" % (code,startdate))
    all = cur.fetchall()
    db.connClose(conn,cur)
    ylist2 = []
    num = 0
    for eachx in xlist:
        isin = 0
        for eachy2 in all:
            if eachy2[0] == eachx:
                isin = isin + 1
        if isin == 0:
            ylist2.append(num)
        else:
            num = num + isin
            ylist2.append(num)
    x = np.arange(0,len(xlist)).tolist()
    plt.plot(x, ylist1,label=code)
    plt.plot(x,ylist2)
    plt.legend()
    plt.savefig(code+'.jpg',dpi=200)
    # plt.show()
    result = {}
    result['close'] = ylist1
    result['report'] = ylist2
    resultfm = pd.DataFrame(result, index=xlist)
    return resultfm
开发者ID:cawind2,项目名称:TestConda32,代码行数:37,代码来源:DataModel.py

示例3:

# 需要导入模块: import DataBase [as 别名]
# 或者: from DataBase import connClose [as 别名]
        #sta = cur.execute('commit')

# 导入全部历史数据
allname = cur.fetchall()
for each in allname:
    print each[0], each[1]
    df = ts.get_hist_data(each[0])
    if df is not None:
        # df.to_csv('e:/stock/%s.csv' % each[0])
        try:
            # 第一次导入,数据库会报错,date类型要从text改为varchar..是主键不在能text上定义
            df.to_sql(each[0], engine, if_exists='append')
        except:
            pass

# 导入时间段数据
allname = cur.fetchall()
for each in allname:
    print each[0], each[1]
    df = ts.get_hist_data(each[0], start='2016-04-26', end='2016-04-26')
    if df is not None:
        # df.to_csv('e:/stock/%s.csv' % each[0])
        try:
            # 第一次导入,数据库会报错,date类型要从text改为varchar..是主键不在能text上定义
            df.to_sql(each[0], engine, if_exists='append')
        except:
            pass

db.connClose(conn,cur)

开发者ID:cawind2,项目名称:TestTu,代码行数:31,代码来源:GetData.py


注:本文中的DataBase.connClose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。