python-oracledB(新的cx_oracle)连接生成notsupportedError dpy-3012错误

发布于 2025-02-04 03:24:30 字数 1047 浏览 1 评论 0 原文

因此,我正在尝试新的OracledB Python库,该库取代了CX_oracle-我不想安装Oracle Instant Client。

un             = 'fred'
pwd            = 'mypass'
host           = 'server.mycompany.net'
port           =  1521
service_name   = 'servicea'


params = oracledb.ConnectParams(host=host, port=port, service_name=service_name)

with oracledb.connect(user=un, 
                      password=pwd,
                      params = params
                      ) as connection:
    
    with connection.cursor() as cursor:
        sql = "select * from dim_drug_product"
        for r in cursor.execute(sql):
            print(r)
 

我只是把这个回来:

文件 c:\ programData \ anaconda3 \ envs \ ariel \ lib \ lib \ site-packages \ oracledB \ errors.py:103, 在_raise_err(error_num,context_error_message,原因,** args) 101消息= f“ {消息} \ n {context_error_message}” 102 exc_type = err_exception_types [error_num // 1000] - > 103从原因

提高exc_type(_error(message))

notsupportederror:dpy-3012:国家角色集ID 871不是 在薄模式下由Python-OracleDB支持

So I am trying the new oracledb python library, which replaces cx_oracle - as I dont want to have to install the oracle instant client.

un             = 'fred'
pwd            = 'mypass'
host           = 'server.mycompany.net'
port           =  1521
service_name   = 'servicea'


params = oracledb.ConnectParams(host=host, port=port, service_name=service_name)

with oracledb.connect(user=un, 
                      password=pwd,
                      params = params
                      ) as connection:
    
    with connection.cursor() as cursor:
        sql = "select * from dim_drug_product"
        for r in cursor.execute(sql):
            print(r)
 

And I just get this back:

File
C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\oracledb\errors.py:103,
in _raise_err(error_num, context_error_message, cause, **args)
101 message = f"{message}\n{context_error_message}"
102 exc_type = ERR_EXCEPTION_TYPES[error_num // 1000]
--> 103 raise exc_type(_Error(message)) from cause

NotSupportedError: DPY-3012: national character set id 871 is not
supported by python-oracledb in thin mode

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

硬不硬你别怂 2025-02-11 03:24:30

薄驾驶员不支持民族角色集871(UTF8,又名CESU-8)。您必须(a)改用厚驱动程序,或者(b)切换到使用字符集AL32UTF8,又称UTF-8。如果您想向较旧的(非标准)字符集请求支持,则可以在此处进行: https://github.com/oracle/python-oracledb/issues

更充分地在评论中回答您的查询:Oracle具有与我们大多数人熟悉的标准化名称不同的字符集。由于Oracle早期参与了Unicode的开发,因此有一些令人困惑的名字!

  • Oracle Name UTF8对应于标准名称CESU-8
  • Oracle名称AL32UTF8对应于标准名称UTF-8,

因此,是的,UTF8和UTF-8不同!

The national character set 871 (UTF8, aka CESU-8) is not supported by the thin driver. You will have to either (a) use the thick driver instead or (b) switch to using the character set AL32UTF8, aka UTF-8. If you would like to request support for the older (non-standard) character set you can do so here: https://github.com/oracle/python-oracledb/issues.

To answer your query in the comment more fully: Oracle has character set names that differ from the standardized names that most of us are familiar with. Since Oracle was involved early on in the development of Unicode there are some confusing names!

  • Oracle name UTF8 corresponds to standard name CESU-8
  • Oracle name AL32UTF8 corresponds to standard name UTF-8

So yes, UTF8 and UTF-8 are different!

情话墙 2025-02-11 03:24:30

您的数据库民族角色是什么?

SELECT value AS db_ncharset
FROM nls_database_parameters
WHERE parameter = 'NLS_NCHAR_CHARACTERSET';

Python-OracledB 1.0.0中有一个关于“民族角色集”(又称NCHAR)支持的限制: https://python-oracledb.readthedocs.io/en/latest/latest/user_guide/globalization.html#character-character-character-sets-sets-sets-sets-and-globalization

如果在薄模式下不支持您的NCHAR字符集,请安装即时客户端并使用厚模式 - 或更新数据库以使用其他NCHAR字符集,或使用AL32UTF8的基本字符集并删除NCHAR列的使用。

What's your database national character set?

SELECT value AS db_ncharset
FROM nls_database_parameters
WHERE parameter = 'NLS_NCHAR_CHARACTERSET';

There is a documented restriction in python-oracledb 1.0.0 about the 'national character set' (aka NCHAR) support: https://python-oracledb.readthedocs.io/en/latest/user_guide/globalization.html#character-sets-and-globalization

If your NCHAR character set isn't supported in Thin mode, then install Instant Client and use thick mode - or update your database to use a different NCHAR character set, or to use a base character set of AL32UTF8 and remove the use of NCHAR columns.

弃爱 2025-02-11 03:24:30

I added support for client encoding in driver's thin mode https://github.com/golubovai/python-oracledb-es. The test cases was supplemented with data containing cyrillic characters and was successfully passed with database in cp1251.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文