【问题标题】:How to accept password in cx_Oracle which contains '@' symbol [duplicate]如何在包含“@”符号的 cx_Oracle 中接受密码 [重复]
【发布时间】:2019-01-29 17:10:21
【问题描述】:

下面是我在 python 上执行的代码。

 import cx_Oracle
 oracle_url = user/p@ssword@hostname:1521/db_service
 cx_Oracle.connect(oracle_url)

它给出错误:ORA-12154: TNS:could not resolve the connect identifier specified

尝试过的解决方案(适用于 powershell 或 CMD):

  1. 在我的密码周围添加“引号”没有帮助。
  2. 添加“引号”也不起作用。

【问题讨论】:

  • 如果将“@”替换为 URL 或百分比编码值:“%40”会怎样?

标签: python python-3.x oracle cx-oracle


【解决方案1】:

您尝试过以下方法吗?

如果使用 SID,

dsn_tns = cx_Oracle.makedsn('server', 'port', 'sid')
conn = cx_Oracle.connect(user='username', password='password', dsn=dsn_tns)

或者如果使用 ServiceName

dsn_tns = cx_Oracle.makedsn('server', 'port', service_name='service_name')
conn = cx_Oracle.connect(user='username', password='password', dsn=dsn_tns)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多