Closed
Description
cx_Oracle.connect() hangs when passing a single connect string with a complex password that works successfully when passed in as 3 separate arguments:
- Update the path for the cx_Oracle.pyd
- Update the user, and tns. You can use the provided password for testing.
- Call the following python sample with
C:\python27\python.exe testcxoracleconnection.py 7.1.2
SAMPLE SCRIPT:
import sys
print(sys.argv[1])
sys.path.append("<PATH TO CX_ORACLE.PYD>\\" + sys.argv[1] + "\\")
import cx_Oracle
print("cx_Oracle version: %s"%cx_Oracle.version)
import platform
os, arch = platform.architecture()
print("OS: {1}\nPlatform Architecture: {0}".format(os, arch))
print("Python Version: %s" % sys.version)
def testcxOracleConnectWithArgs(user, pw, tnsname):
print("Testing Connection to cx_Oracle with args.....")
try:
print("# of args passed: 3")
print(user, pw, tnsname)
connection = cx_Oracle.connect(user, pw, tnsname)
except cx_Oracle.DatabaseError as e:
# Log error as appropriate
raise
print("Connection established: \n\t%s" % connection)
try:
print("Disconnecting.....")
connection.close()
print("Disconnected. \n\nGoodbye! :]\n")
except cx_Oracle.DatabaseError:
pass
def testcxOracleConnectString(connectString):
print("Testing Connection to cx_Oracle with single connect string.....")
# Fails and hangs...
try:
print("# of args passed: 1")
print(connectString)
connection = cx_Oracle.connect(connectString)
except cx_Oracle.DatabaseError as e:
# Log error as appropriate
raise
print("Connection established: \n\t%s" % connection)
try:
print("Disconnecting.....")
connection.close()
print("Disconnected. \n\nGoodbye! :]")
except cx_Oracle.DatabaseError:
pass
user = "SITESPECIFIC"
# This is a valid Oracle Password in 11.2.0.4, 12.1.0.2, 12.2.0,1
pw = "@%+\/'!#$^?:,(){}[]~-_."
rpw = r'%s' % pw
# Works
tnsname = "devtest6"
testcxOracleConnectWithArgs(user, pw, tnsname)
# Hangs
connectString = user + "/" + pw + "@" + tnsname
testcxOracleConnectString(connectString)
print("Done.")
SAMPLE CONSOLE OUTPUT:
7.1.2
cx_Oracle version: 7.1.2
OS: WindowsPE
Platform Architecture: 64bit
Python Version: 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]
Testing Connection to cx_Oracle with args.....
# of args passed: 3
('SITESPECIFIC', "@%+\\/'!#$^?:,(){}[]~-_.", 'devtest6')
Connection established:
<cx_Oracle.Connection to SITESPECIFIC@devtest6>
Disconnecting.....
Disconnected.
Goodbye! :]
Testing Connection to cx_Oracle with single connect string.....
# of args passed: 1
SITESPECIFIC/@%+\/'!#$^?:,(){}[]~-_.@devtest6
Then the script just hangs here on the line connection = cx_Oracle.connect(connectString)
until the process is killed manually.