4

I am trying to connect oracle DB, using the package 'oracledb'. But I can see the below error that states.

Error

File "C:\Users\userid\Anaconda3\lib\site-packages\oracledb\errors.py", line 103, in _raise_err
    raise exc_type(_Error(message)) from cause
oracledb.exceptions.DatabaseError: DPY-4001: no password specified

Note: This is an example code, however, I have already tried with the original configuration details.

The documentation I followed : https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html

Python version: 3.9.12 Coding through Anaconda(jupyter notebook)

Could someone help me to fix this?

code

import oracledb
import os

un = os.environ.get('PYTHON_USERNAME')
pw = os.environ.get('PYTHON_PASSWORD')
cs = os.environ.get('PYTHON_CONNECTSTRING')

with oracledb.connect(user=un, password=pw, dsn=cs) as connection:
    with connection.cursor() as cursor:
        sql = """select sysdate from dual"""
        for r in cursor.execute(sql):
            print(r)
Kevin Tracey
  • 154
  • 1
  • 16
  • Did you check to see that you actually specified a password? If so, how did you do so? That error occurs when the password supplied is empty. In other words, no value is set in the environment variable PYTHON_PASSWORD. – Anthony Tuininga Jul 29 '22 at 13:13

0 Answers0