from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, declarative_base # 数据库连接字符串 SQLALCHEMY_DATABASE_URL = "mysql+pymysql://root:mypassword12@127.0.0.1:3306/lianai" # 创建数据库引擎 engine = create_engine(SQLALCHEMY_DATABASE_URL) # 创建会话本地类 SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) # 声明基类 Base = declarative_base()