コード例 #1
0
def main():
    cursor = conn.getConfig()
    pdata = haveData(cursor)
    if pdata == 0:
        getBasics(cursor)
    else:
        cursor.execute("truncate table stock_basics")
        getBasics(cursor)
コード例 #2
0
def main():
    cursor = conn.getConfig()
    pdata = haveData(cursor)
    if pdata == 0:
        getProfit(cursor)
    else:
        cursor.execute("truncate table stock_profit")
        print("发现数据,清除完毕")
        getProfit(cursor)
コード例 #3
0
def main():
    cursor = conn.getConfig()
    pdata = haveData(cursor)
    if pdata == 0:
        getDebtpaying(cursor)
    else:
        cursor.execute("truncate table stock_debtpaying")
        print("发现数据,清除完毕")
        getDebtpaying(cursor)
コード例 #4
0
def main():
    cursor = conn.getConfig()
    # print(cursor)
    pdata = haveData(cursor)
    if pdata == 0:
        getGrowth(cursor)
    else:
        cursor.execute("truncate table stock_growth")
        print("发现数据,清除完毕")
        getGrowth(cursor)
コード例 #5
0
def main():
    cursor = conn.getConfig()
    # print(cursor)
    pdata = haveData(cursor)
    if pdata == 0:
        getShMargins(cursor)
    else:
        cursor.execute("truncate table stock_sh_margins")
        print("发现数据,清除完毕")
        getShMargins(cursor)
コード例 #6
0
def main():
    cursor = conn.getConfig()
    #getForecast(cursor)
    pdata = haveData(cursor)
    if pdata == 0:
        getForecast(cursor)
    else:
        cursor.execute("truncate table stock_forecast")
        print("发现数据,清除完毕")
        getForecast(cursor)
コード例 #7
0
def main():
    cursor = conn.getConfig()
    # print(cursor)
    pdata = haveData(cursor)
    if pdata == 0:
        getFundHoldings(cursor)
    else:
        cursor.execute("truncate table stock_fund_holdings")
        print("发现数据,清除完毕")
        getFundHoldings(cursor)
コード例 #8
0
def main():
    #======================================================================
    cursor = conn.getConfig()
    # print(cursor)
    pdata = haveData(cursor)
    if pdata == 0:
        getSzMarginDetails(cursor)
    else:
        cursor.execute("truncate table stock_sz_margin_details")
        print("发现数据,清除完毕")
        getSzMarginDetails(cursor)
コード例 #9
0
def getCSV(code, url):
    fordername = 'AllStockData'
    filename = str(code) + '.CSV'
    if not os.path.isdir(fordername):
        print("mkdir")
        os.mkdir(fordername)
    with request.urlopen(url) as web:
        # 为防止编码错误,使用二进制写文件模式
        print(web)
        with open(fordername + os.path.sep + filename, 'wb') as outfile:
            outfile.write(web.read())
            print("write OK " + str(code))
    #print("id1")

    #print(id(cursor))
    import common.GetMysqlConn as conn2
    cursor = conn2.getConfig()
    #print("Id2")
    # print(id(cursor))
    saveInDB(code, cursor)

    print("一只股票入库完毕")
    # 删除CSV文件
    os.remove(fordername + filename)
コード例 #10
0
import pandas as pd
import time
from multiprocessing import Pool
import uuid
import os
import numpy as np
import re
import time

# 导入连接文件
import sys
sys.path.append("..")
import common.GetMysqlConn as conn

# 获取全局数据库连接
cursor = conn.getConfig()


# 查询数据库中STOCK_XXXXXX的所有表,提取出股票代码与最大日期
def getTable():
    # 提取股票代码
    cursor.execute("show tables")
    curesult = cursor.fetchall()
    table_re = re.compile(r'stock_\d+')
    tableNameList = []
    for i in curesult:
        for key in i:
            # print(i[key])
            if table_re.match(i[key]):
                tableNameList.append(i[key])
    #print(tableNameList)