Sqlalchemy-如何在Oracle数据库中指定所有者 [英] Sqlalchemy - How to Specify Owner in Oracle database
问题描述
我正在尝试从数据库中反映一个现有表:
I am trying to reflect an existing table from my database:
engine = sqlalchemy.create_engine("oracle://username:password@id", ...)
meta = sqlalchemy.MetaData()
myTable = sqlalchemy.Table("myTable", meta, autoload=True, autoload_with=engine,
oracle_resolve_synonyms=True)
那给了我一个错误:
AssertionError:模式中可见多个表,您必须指定所有者
AssertionError: There are multiple tables visible to the schema, you must specify owner
如何在sqlalchemy中指定所有者? 文档没有提及有关指定拥有者.该表实际上是同义词,所以我必须使用oracle_resolve_synonyms
.从技术上讲,我可以执行原始查询,但这不是我想要做的.
How do I specify the owner in sqlalchemy? The documentation does not mention anything about specifying owners. the table is actually a synonym so I have to use oracle_resolve_synonyms
. I can technically execute raw queries but that is not something that I want to do.
推荐答案
Here's the docs on MetaData: http://docs.sqlalchemy.org/en/latest/core/metadata.html#sqlalchemy.schema.MetaData
您可能想用架构所有者实例化MetaData:
You probably want to instantiate MetaData with the schema owner:
meta = sqlalchemy.MetaData(engine, schema='ora_schema_owner')
这篇关于Sqlalchemy-如何在Oracle数据库中指定所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!