CodexBloom - Programming Q&A Platform

OCI Data Science Notebook how to to Connect to Oracle Database with SSL Configuration

👀 Views: 79 💬 Answers: 1 📅 Created: 2025-06-07
oci cx-oracle database-connection Python

I'm writing unit tests and I'm currently working on a data science project using Oracle Cloud Infrastructure (OCI) Data Science Notebooks, and I'm having trouble connecting to an Oracle Database instance that requires SSL for secure connections... I have followed the official documentation, but I keep working with the following behavior: ``` ORA-28000: the account is locked ``` I suspect it might be related to the SSL configuration. I set up my connection string as follows: ```python import cx_Oracle # Set up connection parameters username = 'my_user' password = 'my_password' host = 'my_db_host' port = 1521 service_name = 'my_service' binary = cx_Oracle.DatabaseType.SSL # Connection string connection_string = f'{username}/{password}@//{host}:{port}/{service_name}' try: connection = cx_Oracle.connect(connection_string, mode=binary) print('Connection successful!') except cx_Oracle.behavior as e: print(f'behavior occurred: {e}') ``` I have also verified that the user account is not locked directly in the database using SQL Developer. Additionally, I have set up the SSL certificates correctly, but I still face the same scenario. I checked the following configurations: - The database listener is set up to accept SSL connections. - I have the correct wallet location and I’ve set the environment variable `TNS_ADMIN` to point to my wallet folder. - I’m using `cx_Oracle` version 8.2, which should support SSL. Is there something I'm missing in my connection setup, or could the question be related to the user account in the database despite verifying it wasn't locked? Any guidance would be appreciated! My team is using Python for this web app. Hoping someone can shed some light on this. Thanks for any help you can provide!