Sqlalchemy-如何在Oracle数据库中指定所有者 [英] Sqlalchemy - How to Specify Owner in Oracle database

查看:355
本文介绍了Sqlalchemy-如何在Oracle数据库中指定所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从数据库中反映一个现有表:

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.

推荐答案

以下是MetaData上的文档:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆