示例#1
0
def main(): 
    '''''
    主调函数,可以通过参数调整实现分批下载
    ''' 
    global engine,sleep_time,symbols 
    sleep_time=5 
    windStock=WindStock() 
    engine= create_engine('mysql://*****:*****@localhost/invest?charset=utf8') 
    #start_date='20100101' 
    #end_date='20131231' 
    #symbols=windStock.getAStockCodesFromCsv()#通过文件获取股票代码 
    #symbols=windStock.getAStockCodesWind() 
    #通过Wind API获取股票代码,默认取最新的,可以指定取历史某一日所有A股代码 
    #symbols=['000001.SZ', '000002.SZ', '000004.SZ']#通过直接赋值获取股票代码用于测试 
    #print (symbols) 
    #windStock.AStockHisData(symbols,start_date,end_date) 
    for iin range(2013,1990,-1): 
         start_date=str(i)+'0101' 
         end_date=str(i)+'1231' 
         print (start_date,end_date,'Starting') 
         symbols=windStock.getAStockCodesWind() 
         windStock.AStockHisData(symbols,start_date,end_date) 
         print (start_date,end_date,'Finished') 
示例#2
0
from sqlalchemyimport create_engine
from sqlalchemy.ext.declarativeimport declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.pool import NullPool

DB = 'postgresql+psycopg2:///hostview'
engine = create_engine(DB, echo=False, poolclass=NullPool)
Base = declarative_base(engine)

class Tsrtt(Base):
    __tablename__ = 'tsrtt'
    __table_args__ = {'autoload':True}
示例#3
0
import numpy as np
import pandas as pd 
import datetime as dt
import sqlalchemy

from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemyimport create_engine, func

from flask import Flask, jsonify

engine = create_engine("sqlite:///Resource/hawaii.sqlite")

#Reflect Existing Database into a New Model
Base = automap_base()
#Reflect the Tables
Base.prepare(engine, reflect=True)

#Save References to each Table
Measurement = Base.classes.measurement
Station = Base.classes.station

#Create Session (link) from Python to the DB
session = Session(engine)

#Flask Setup
app = Flask(_name_)

#Flask Routes
@app.route("/")
def welcome():