注册

dm8 dmsqlalchemy获取物化视图报错

DM_371826 2025/11/21 68 0

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:dm8
【操作系统】:windows
【CPU】:i5
【问题描述】*:
背景:基于dmpython和dmsqlalchemy来读取达梦数据库内容。当设置读取视图时,获取报错。

@reflection.cache
def get_materialized_view_names(
self, connection, schema=None, dblink=None, _normalize=True, **kw
):
schema = self.denormalize_name(schema or self.default_schema_name)

text = "SELECT a_mviews.mview_name FROM all_mviews a_mviews WHERE schid = (select id from sysobjects where name = '%(schema)s' and type$ = 'SCH');"
text = text % {'schema': schema}
rp = connection.execute(sql.text(text))
mat_view_names = rp.fetchall()

if _normalize:
return [self.normalize_name(row[0]) for row in mat_view_names]
else:
return [row[0] for row in mat_view_names]

qlalchemy.exc.DatabaseError: (dmPython.DatabaseError) [CODE:-2106]第1 行附近出现错误:
无效的表或视图名[ALL_MVIEWS]
[SQL: SELECT a_mviews.mview_name FROM all_mviews a_mviews WHERE schid = (select id from sysobjects where name = 'XXX' and type$ = 'SCH');]
(Background on this error at: https://sqlalche.me/e/20/4xp6).
请问不修改源码或者绕过物化视图的解决方法

回答 0
暂无回答
扫一扫
联系客服