Python 使用双引号创建的表选择列失败

Python 使用双引号创建的表选择列失败,python,sql,sqlalchemy,apache-superset,Python,Sql,Sqlalchemy,Apache Superset,我将一个postgresql数据库连接到Apache超集,并正在使用他们的SQL编辑器。我遇到了一个问题,无法在具有关联id的两个表之间进行左联接 SELECT id, profile_name FROM "ProductionRun" LEFT JOIN "StatsAssociation" ON "ProductionRun".id = "StatsAssociation".production_run_id;

我将一个postgresql数据库连接到Apache超集,并正在使用他们的SQL编辑器。我遇到了一个问题,无法在具有关联id的两个表之间进行左联接

SELECT id, profile_name FROM "ProductionRun"
LEFT JOIN "StatsAssociation" ON "ProductionRun".id = "StatsAssociation".production_run_id;
我上面的语法正确吗?这些表必须用双引号引用,因为它们是区分大小写创建的。这只返回ProductionRun表的id和profile_name列,而不与StatAssociation表联接

我使用sqlalchemy创建了表,下面是表模式:

生产运行

class ProductionRun(Base):
    __tablename__ = 'ProductionRun'

    id = Column(Integer, primary_key=True, autoincrement=True)
    profile_name = Column(String, nullable=False)
国家协会

class StatsAssociation(Base):
    __tablename__ = 'StatsAssociation'

    production_run_id = Column(Integer, ForeignKey('ProductionRun.id'), primary_key=True)
    stats_package_id = Column(Integer, ForeignKey('StatsPackage.id'), unique=True, nullable=False)

    stats_package = relationship('StatsPackage', back_populates='stats_association', cascade='all,delete')
    production_run = relationship('ProductionRun', back_populates='stats_association')

当我查看这些表时,它们都存在,StatAssociation具有production\u run\u id列,该列与ProductionRun共享相同的id。

这最初是作为注释发布的


您没有从StatAssociation表中指定任何列,因此预计不会显示任何内容。要在SELECT查询的输出中获取列,您需要列出它们——如果您在SELECT中使用TableName.*或*,我目前可以想到的唯一例外

例如,刚开始时:

SELECT id, profile_name, production_run_id 
FROM ... 

在哪里。。。是查询的其余部分。

您没有从StatAssociation表中指定任何列,因此预计不会显示任何内容。要在SELECT查询的输出中获取列,需要列出它们。例如,刚开始时:选择id、配置文件名称、生产运行id。。。哪里这是您的问题的其余部分。能否将“^”更改为答案?我是SQL新手,所以这并不像看上去那么明显。当然,不用担心。我们曾经都是新人: