[Python] Python connect to Oracle database with TCPS

Discussão em 'Python' iniciado por Stack, Fevereiro 3, 2025.

  1. Stack

    Stack Membro Participativo

    trying to connect Oracle database with TCPS connection from python but its failing with ORA-28759: failure to open file.

    I am not sure what I need to be configured in wallet when connecting from local/other server to database on different server.

    import os
    import os.path
    import sys
    import cx_Oracle

    ORACLE_VERSION=19.3
    os.environ['ORACLE_BASE']=/Users/machild/Documents/oracle
    os.environ['ORACLE_HOME']='$ORACLE_BASE/product/instantclient/$ORACLE_VERSION'
    os.environ['DYLD_LIBRARY_PATH']='$ORACLE_HOME/lib'
    os.environ['OCI_DIR']='$DYLD_LIBRARY_PATH'
    os.environ['TNS_ADMIN']='$ORACLE_BASE/network/admin'


    Connection_String ='username/password@(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCPS)(HOST=orclconsapp.vci.map.com)(PORT=1587)))(CONNECT_DATA = (SERVICE_NAME=cons_app)))'

    connection = cx_Oracle.connect(Connection_String)


    cursor = connection.cursor()
    cursor.execute("""select to_char(sysdate,'mm/dd/yyyy') from dual""")
    for result in cursor:
    print(result)



    **Its failing with below error**

    Traceback (most recent call last):
    File "/Users/machild/Documents/oracle_conn.py", line 16, in <module>
    connection = cx_Oracle.connect(Connection_String)
    cx_Oracle.DatabaseError: ORA-28759: failure to open file


    I think it would need a wallet but not sure what exactly goes in wallet if we want to connect from external server( not where database is running). Any ideas?

    Continue reading...

Compartilhe esta Página