|
|
|
import sqlalchemy
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
from sqlalchemy.orm import declarative_base, sessionmaker
|
|
|
|
from sqlalchemy import Column, Integer, String, DATE, Enum
|
|
|
|
|
|
|
|
# 创建数据引擎
|
|
|
|
DB_URI = "mysql+pymysql://root:Sxzgx1209@home.rogersun.cn:3306/lottery"
|
|
|
|
engine = create_engine(DB_URI, echo=True)
|
|
|
|
|
|
|
|
# 生成基类
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
|
|
|
|
|
|
# 生成数据表对象
|
|
|
|
class History(Base):
|
|
|
|
__tablename__ = 'history' # 定义表名
|
|
|
|
|
|
|
|
# 定义表结构
|
|
|
|
id = Column(Integer, autoincrement=True, primary_key=True)
|
|
|
|
dateId = Column(String(20), nullable=False)
|
|
|
|
openDate = Column(DATE, nullable=False)
|
|
|
|
red = Column(String(200), nullable=False)
|
|
|
|
blue = Column(String(10), nullable=False)
|
|
|
|
|
|
|
|
|
|
|
|
class BlueForecastFiveAll(Base):
|
|
|
|
__tablename__ = 'blue_forecast_five_all' # 定义表名
|
|
|
|
|
|
|
|
# 定义表结构
|
|
|
|
id = Column(Integer, autoincrement=True, primary_key=True)
|
|
|
|
dateId = Column(String(20), nullable=False, comment='期号')
|
|
|
|
real_blue = Column(String(10), comment='真实的蓝球数据')
|
|
|
|
prv = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往前推5期,计算蓝球出现概率')
|
|
|
|
prv_index = Column(Integer, comment='根据实际结果计算蓝球的index位置')
|
|
|
|
post = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往后推5期,计算蓝球出现概率')
|
|
|
|
post_index = Column(Integer, comment='根据实际结果计算蓝球的index位置')
|
|
|
|
history = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中计算每个蓝球出现的概率')
|
|
|
|
history_index = Column(Integer, comment='历史中的蓝球索引')
|
|
|
|
|
|
|
|
|
|
|
|
class BlueForecastThreeAll(Base):
|
|
|
|
__tablename__ = 'blue_forecast_three_all' # 定义表名
|
|
|
|
|
|
|
|
# 定义表结构
|
|
|
|
id = Column(Integer, autoincrement=True, primary_key=True)
|
|
|
|
dateId = Column(String(20), nullable=False, comment='期号')
|
|
|
|
real_blue = Column(String(10), comment='真实的蓝球数据')
|
|
|
|
prv = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往前推5期,计算蓝球出现概率')
|
|
|
|
prv_index = Column(Integer, comment='根据实际结果计算蓝球的index位置')
|
|
|
|
post = Column(String(500), nullable=False,
|
|
|
|
comment='根据当前一期的蓝球,从历史数据中往后推5期,计算蓝球出现概率')
|
|
|
|
post_index = Column(Integer, comment='根据实际结果计算蓝球的index位置')
|
|
|
|
history = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中计算每个蓝球出现的概率')
|
|
|
|
history_index = Column(Integer, comment='历史中的蓝球索引')
|
|
|
|
|
|
|
|
|
|
|
|
class RedForecastAll(Base):
|
|
|
|
__tablename__ = 'red_forecast_all' # 定义表名
|
|
|
|
|
|
|
|
# 定义表结构
|
|
|
|
id = Column(Integer, autoincrement=True, primary_key=True)
|
|
|
|
dateId = Column(String(20), nullable=False, comment='期号-指预测数据根据哪一期数据计算')
|
|
|
|
history = Column(String(500), nullable=False, comment='历史中红球的出现概率偏差')
|
|
|
|
history_random = Column(String(256), comment='根据历史差异随机计算的红球数据')
|
|
|
|
history_random_index = Column(String(256), comment='预测红球数据对应的index')
|
|
|
|
history_random_index_group = Column(String(256), comment='预测红球数据对应的index分布')
|
|
|
|
last = Column(String(500), nullable=False, comment='根据上一期红球结果计算历史中红球的出现概率')
|
|
|
|
last_random = Column(String(256), comment='随机计算的红球数据')
|
|
|
|
last_random_index = Column(String(256), comment='预测红球数据对应的index')
|
|
|
|
last_random_index_group = Column(String(256), comment='预测红球数据对应的index分布')
|
|
|
|
real_red = Column(String(256), comment='下一期的真实的红球数据')
|
|
|
|
real_red_index_history = Column(String(100), comment='真实红球在此次预测中的索引位置')
|
|
|
|
real_red_index_group_history = Column(String(100), comment='真实红球在此次预测中的索引位置的分布')
|
|
|
|
real_red_index_last = Column(String(100), comment='真实红球在此次预测中的索引位置')
|
|
|
|
real_red_index_group_last = Column(String(100), comment='真实红球在此次预测中的索引位置的分布')
|
|
|
|
|
|
|
|
|
|
|
|
class IndexGroup(Base):
|
|
|
|
__tablename__ = 'index_group' # 定义表名
|
|
|
|
|
|
|
|
# 定义表结构
|
|
|
|
id = Column(Integer, primary_key=True, comment='主键')
|
|
|
|
type = Column(Enum('history', 'last'), default='history', nullable=False, comment='索引类型')
|
|
|
|
index_group = Column(String(100), nullable=False, comment='用于手机索引组数据')
|
|
|
|
|
|
|
|
|
|
|
|
# 创建数据表,下面部分没有联想
|
|
|
|
Base.metadata.create_all(engine)
|
|
|
|
|
|
|
|
# Session_class = sessionmaker(bind=engine) # 创建与数据引擎的绑定会话类
|
|
|
|
# db_session = Session_class() # 实例化session连接
|