python-oracledB(新的cx_oracle)连接生成notsupportedError dpy-3012错误
因此,我正在尝试新的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支持
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
薄驾驶员不支持民族角色集871(UTF8,又名CESU-8)。您必须(a)改用厚驱动程序,或者(b)切换到使用字符集AL32UTF8,又称UTF-8。如果您想向较旧的(非标准)字符集请求支持,则可以在此处进行: https://github.com/oracle/python-oracledb/issues 。
更充分地在评论中回答您的查询:Oracle具有与我们大多数人熟悉的标准化名称不同的字符集。由于Oracle早期参与了Unicode的开发,因此有一些令人困惑的名字!
因此,是的,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!
So yes, UTF8 and UTF-8 are different!
您的数据库民族角色是什么?
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?
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.
我添加了对客户端薄模式中的客户编码的支持,。测试案例补充了包含西里尔字符的数据,并在CP1251中成功通过了数据库。
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.