def main(): cursor = conn.getConfig() pdata = haveData(cursor) if pdata == 0: getBasics(cursor) else: cursor.execute("truncate table stock_basics") getBasics(cursor)
def main(): cursor = conn.getConfig() pdata = haveData(cursor) if pdata == 0: getProfit(cursor) else: cursor.execute("truncate table stock_profit") print("发现数据,清除完毕") getProfit(cursor)
def main(): cursor = conn.getConfig() pdata = haveData(cursor) if pdata == 0: getDebtpaying(cursor) else: cursor.execute("truncate table stock_debtpaying") print("发现数据,清除完毕") getDebtpaying(cursor)
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)
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)
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)
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)
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)
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)
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)