开发者

select table from other schema

开发者 https://www.devze.com 2023-03-06 11:13 出处:网络
I have a table from sche开发者_JAVA百科ma \"test\": class AttributeConversion(Base): __tablename__ = \'test.attribute_conversion\'

I have a table from sche开发者_JAVA百科ma "test":

class AttributeConversion(Base):
    __tablename__ = 'test.attribute_conversion'

How to select records from this table?

SQLAlchemy generates SQL:

select * from "test.attribute_conversion"

But it doesn't work. The correct query must be:

select * from test.attribute_conversion  (without quotes)


You can explicity specify a schema name for a table:

class AttributeConversion(Base)
    __tablename__ = 'attribute_conversion'
    __table_args__ = {'schema' : 'test'}

See documentation on specifying the schema name.

0

精彩评论

暂无评论...
验证码 换一张
取 消