From 1334c16189c12b1ad8d53faa26c40bf1e8077e95 Mon Sep 17 00:00:00 2001 From: roger Date: Tue, 27 Jun 2023 21:32:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=9A=8F=E6=9C=BA=E6=95=B0?= =?UTF-8?q?=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blue_forecast.py | 2 +- blue_total_rate.py | 2 +- new_blue_forecast.py | 2 +- orm/blue_forecast.py | 0 orm/main.py | 0 orm/orm_db.py | 79 ++++++++++++++++++++++++++++++++++++++++++++ orm/real_index.py | 0 orm/red_forecast.py | 0 real_index.py | 2 +- red_forecast.py | 2 +- 10 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 orm/blue_forecast.py create mode 100644 orm/main.py create mode 100644 orm/orm_db.py create mode 100644 orm/real_index.py create mode 100644 orm/red_forecast.py diff --git a/blue_forecast.py b/blue_forecast.py index 3402358..426319c 100644 --- a/blue_forecast.py +++ b/blue_forecast.py @@ -4,7 +4,7 @@ from functools import reduce from pymysql.cursors import DictCursor db = { - 'host': 'home.rogersun.online', + 'host': 'home.rogersun.cn', 'user': 'root', 'password': 'Sxzgx1209', 'database': 'lottery' diff --git a/blue_total_rate.py b/blue_total_rate.py index 5fe767f..5fbaa6b 100644 --- a/blue_total_rate.py +++ b/blue_total_rate.py @@ -5,7 +5,7 @@ from blue_forecast import dict_sort, dict_rate from pymysql.cursors import DictCursor db = { - 'host': 'home.rogersun.online', + 'host': 'home.rogersun.cn', 'user': 'root', 'password': 'Sxzgx1209', 'database': 'lottery' diff --git a/new_blue_forecast.py b/new_blue_forecast.py index 00f4d5f..c28ad2c 100644 --- a/new_blue_forecast.py +++ b/new_blue_forecast.py @@ -5,7 +5,7 @@ from functools import reduce from pymysql.cursors import DictCursor db = { - 'host': 'home.rogersun.online', + 'host': 'home.rogersun.cn', 'user': 'root', 'password': 'Sxzgx1209', 'database': 'lottery' diff --git a/orm/blue_forecast.py b/orm/blue_forecast.py new file mode 100644 index 0000000..e69de29 diff --git a/orm/main.py b/orm/main.py new file mode 100644 index 0000000..e69de29 diff --git a/orm/orm_db.py b/orm/orm_db.py new file mode 100644 index 0000000..8a8e1b3 --- /dev/null +++ b/orm/orm_db.py @@ -0,0 +1,79 @@ +import sqlalchemy +from sqlalchemy import create_engine +from sqlalchemy.orm import declarative_base +from sqlalchemy import Column, Integer, String, DATE + +# 创建数据引擎 +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_five = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往前推5期,计算蓝球出现概率') + prv_index = Column(Integer, comment='根据实际结果计算蓝球的index位置') + post_five = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往后推5期,计算蓝球出现概率') + post_index = Column(Integer, comment='根据实际结果计算蓝球的index位置') + history_total = 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_three = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往前推5期,计算蓝球出现概率') + prv_index = Column(Integer, comment='根据实际结果计算蓝球的index位置') + post_three = Column(String(500), nullable=False, + comment='根据当前一期的蓝球,从历史数据中往后推5期,计算蓝球出现概率') + post_index = Column(Integer, comment='根据实际结果计算蓝球的index位置') + history_total = 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='期号-指预测数据根据哪一期数据计算') + red_rate = Column(String(500), nullable=False, comment='根据上一期红球结果计算历史中红球的出现概率') + random_red_num = Column(String(256), comment='随机计算的红球数据') + random_red_index = Column(String(256), comment='预测红球数据对应的index') + random_red_index_group = Column(String(256), comment='预测红球数据对应的index分布') + real_red = Column(String(256), comment='下一期的真实的红球数据') + real_red_index = Column(String(100), comment='真实红球在此次预测中的索引位置') + real_red_index_group = Column(String(100), comment='真实红球在此次预测中的索引位置的分布') + + +# 创建数据表,下面部分没有联想 +Base.metadata.create_all(engine) + + +from sqlalchemy.orm import sessionmaker + +Session_class = sessionmaker(bind=engine) # 创建与数据引擎的绑定会话类 +session = Session_class() # 实例化session连接 diff --git a/orm/real_index.py b/orm/real_index.py new file mode 100644 index 0000000..e69de29 diff --git a/orm/red_forecast.py b/orm/red_forecast.py new file mode 100644 index 0000000..e69de29 diff --git a/real_index.py b/real_index.py index 905176b..79a5e5f 100644 --- a/real_index.py +++ b/real_index.py @@ -4,7 +4,7 @@ from functools import reduce from pymysql.cursors import DictCursor db = { - 'host': 'home.rogersun.online', + 'host': 'home.rogersun.cn', 'user': 'root', 'password': 'Sxzgx1209', 'database': 'lottery' diff --git a/red_forecast.py b/red_forecast.py index 56fdaa2..27ce479 100644 --- a/red_forecast.py +++ b/red_forecast.py @@ -7,7 +7,7 @@ from blue_forecast import dict_sort, dict_rate from lottery_random import new_num db = { - 'host': 'home.rogersun.online', + 'host': 'home.rogersun.cn', 'user': 'root', 'password': 'Sxzgx1209', 'database': 'lottery'