在密码中带有@符号的Oracle连接字符串 [英] Oracle connection string with at sign @ in pasword
本文介绍了在密码中带有@符号的Oracle连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用连接字符串连接到oracle的代码:
I have a code that connect to oracle using connection string:
conn = cx_Oracle.connect('username/password@server:port/services')
但是问题是我的密码包含@字符,所以它可能会变成
But the problem is my password contain @ character so it may become
conn = cx_Oracle.connect('username/p@ssword@server:port/services')
返回
DatabaseError:ORA-12154:TNS:无法解析连接标识符 指定
DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified
在此设置下,我将Django与Oracle配合使用
I use Django with Oracle with this settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'Services',
'USER': 'user',
'PASSWORD': 'p@ssword',
'HOST': 'ip',
'PORT': 'port',
}
}
我无法更改密码:(有人知道这个问题吗?
I cant change password :( Does anyone know this problem?
推荐答案
我还没有尝试过cx_Oracle,但是您可以通过指定各个参数来进行连接-
I haven't tried cx_Oracle, but you might be able to connect by specifying the individual parameters -
conn = cx_Oracle.connect(user='username', password='p@ssword', dsn='server:port/services')
OR
dsn_tns = cx_Oracle.makedsn('server', 'port', 'services')
conn = cx_Oracle.connect(user='username', password='p@ssword', dsn=dsn_tns)
这篇关于在密码中带有@符号的Oracle连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文