当前位置:   article > 正文

sqlalchemy查询MySQL视图_SqlAlchemy:动态查询

sqlalchemy动态查询

虽然还没有测试,但使用SQLAlchemy ORM,您可以将表链接在一起,如下所示:from sqlalchemy import create_engine, Integer, String

from sqlalchemy.ext.declarative import declarative_base

from sqlalchemy import Column, ForeignKey

from sqlalchemy.orm import relationship

from asgportal.database import Session

Engine = create_engine('mysql+mysqldb://user:password@localhost:3306/mydatabase', pool_recycle=3600)

Base = declarative_base(bind=Engine)

session = Session()

session.configure(bind=Engine)

class DBOrganization(Base):

__tablename__ = 'table_organization'

id = Column(Integer(), primary_key=True)

name = Column(ASGType.sa(ASGType.STRING))

class DBEmployee(Base):

__tablename__ = 'table_employee'

id = Column(Integer(), primary_key=True)

n

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/527503
推荐阅读
相关标签
  

闽ICP备14008679号