[Python] How to fix the error 'DPY-4001: no password specified' of oracledb in python

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    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)

    Continue reading...

Compartilhe esta Página