we have been using sqlalchemy successfully to connect to Oracle. Just now our organization is moving to encrypted Oracle database and we have been asked to switch to the encrypted database.
The sample code given to me by the database engineering team is which uses cx_Oracle directly is:
import cx_Oracle
dsn = """(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcps)(HOST=test_host)(PORT=1531)))
(CONNECT_DATA=(SERVICE_NAME=test_service)))"""
connection = cx_Oracle.connect(user="test", password="test", dsn=dsn, encoding="UTF-8")
However, when I try to connect to the database using sqlalchemy using : oracle+cx_oracle://test:test@test_host:1531/test_service
I get an error : (cx_Oracle.DatabaseError) ORA-12547: TNS:lost contact\n(Background on this error at: http://sqlalche.me/e/13/4xp6)
I suspect that it is the protocol tcps that needs to be set.
I tried the following connection string :
protocol_url = 'oracle+cx_oracle://test:test@test_host:1531?service_name=test_service&protocol=tcps'
I get the following error :
ValueError: invalid literal for int() with base 10: '1531?service_name=test_service&protocol=tcps'
Is there a way to use sqlalchemy to connect to Oracle on an encrypted port?
EDIT : I went through the steps listed in Python connect to Oracle database with TCPS I still get the error : sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-12547: TNS:lost contact
NOTE: I know that I can successfully connect to Oracle with encryption using a direct cx_Oracle connection.