更新了一点,没思路了

main
roger_home_pc 1 year ago
parent 1334c16189
commit f1bbed6066
  1. 12
      orm/blue_forecast.py
  2. 7
      orm/orm_db.py
  3. 2
      orm/real_index.py

@ -0,0 +1,12 @@
from orm_db import *
from sqlalchemy import select, desc
try:
get_last_data_stmt = select(History).order_by(desc('id')).limit(1)
last_data_result = db_session.execute(get_last_data_stmt).scalar()
print(last_data_result)
except Exception as e:
print(e)
last_blue = last_data_result.blue
print(last_blue)

@ -1,6 +1,6 @@
import sqlalchemy import sqlalchemy
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy import Column, Integer, String, DATE from sqlalchemy import Column, Integer, String, DATE
# 创建数据引擎 # 创建数据引擎
@ -72,8 +72,5 @@ class RedForecastAll(Base):
# 创建数据表,下面部分没有联想 # 创建数据表,下面部分没有联想
Base.metadata.create_all(engine) Base.metadata.create_all(engine)
from sqlalchemy.orm import sessionmaker
Session_class = sessionmaker(bind=engine) # 创建与数据引擎的绑定会话类 Session_class = sessionmaker(bind=engine) # 创建与数据引擎的绑定会话类
session = Session_class() # 实例化session连接 db_session = Session_class() # 实例化session连接

@ -0,0 +1,2 @@
from orm_db import *
Loading…
Cancel
Save