Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

OracleDB does not work in Python 3.9.13 on Cloud ADB

fmzMay 28 2022

Hi,
I am trying to connect to my Always Free ADB with Python 3.9.13 (fresh installed today) and OracleDB
without success:
Traceback (most recent call last):
connection = oracledb.connect(user='northwind', password='blahblah', dsn='db21cpresent_medium')
File "C:\Python39\lib\site-packages\oracledb\connection.py", line 995, in wrapped
return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
File "C:\Python39\lib\site-packages\oracledb\connection.py", line 124, in __init__
impl.connect(params_impl)
File "src\oracledb\impl/thin/connection.pyx", line 309, in oracledb.thin_impl.ThinConnImpl.connect
File "src\oracledb\impl/thin/connection.pyx", line 164, in oracledb.thin_impl.ThinConnImpl._connect_with_params
File "src\oracledb\impl/thin/crypto.pyx", line 125, in oracledb.thin_impl.get_ssl_socket
File "C:\Python39\lib\ssl.py", line 501, in wrap_socket
return self.sslsocket_class._create(
File "C:\Python39\lib\ssl.py", line 1041, in _create
self.do_handshake()
File "C:\Python39\lib\ssl.py", line 1310, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1129)
The same connection works with cx_Oracle fine.
Regards, Friedhold

This post has been answered by Christopher Jones-Oracle on May 31 2022
Jump to Answer

Comments

Christopher Jones-Oracle
Answer

Read the documentation: https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#connecting-to-oracle-cloud-autonomous-databases
The default 'Thin' mode of python-oracledb you are using needs the wallet in PEM file format. This is a requirement of the Python libraries now being used, since Thin mode doesn't use the Oracle Client libraries (which use a .sso file). Recent wallet.zip files include a .pem file. If you don't have one, then re-download the wallet.zip file. Or you can convert the .p12 file in your wallet.zip to a .pem file using the utility script in the documentation.
Pass the directory (not including the filename) containing the wallet when you connect. You also need to specify the wallet password:
connection = oracledb.connect(user='northwind', password=pw, dsn='db21cpresent_medium',
config_dir="c:\the\dir\containing\the\tnsnames\file",
wallet_location=r"c:\the\dir\containing\the\pem\file", wallet_password=wpw,
)
Alternatively, enable 'Thick' mode and you won't need the above.
A third option is to use 1-way TLS. That is also in the documentation

Marked as Answer by fmz · May 31 2022
fmz

Great thanks, Christopher!
It works with the specification of the three parameters (Windows 10) now:
connection = oracledb.connect(user='northwind', password=pw, dsn='db21cpresent_medium',
config_dir="c:\\my\\wallet\\dir",
wallet_location="c:\\my\\wallet\\dir",
wallet_password=wpw
)
In my wallet-dir there are the tnsname.ora and ewallet.pem files after unzipping of the wallet.zip file.
Ciao, Friedhold

dversoza

Thanks! Fixed the issue for me here!

1 - 3

Post Details

Added on May 28 2022
3 comments
1,327 views