本文介绍了从其他模式中选择表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个来自模式test"的表:
I have a table from schema "test":
class AttributeConversion(Base):
__tablename__ = 'test.attribute_conversion'
如何从该表中选择记录?
How to select records from this table?
SQLAlchemy 生成 SQL:
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'}
请参阅有关指定架构名称的文档.
这篇关于从其他模式中选择表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!