1

I have launched an RDS Oracle database instance and wanted to connect it using a python code. i did something using cx_oracle but not worked out. Any suggestions/ help would be great !

Thanks in Advance

import cx_Oracle

connstr = 'username/[email protected]:1521/orcl'
conn = cx_Oracle.connect(connstr)

Error message I am getting is:

cx_Oracle.DatabaseError: DPI-1047: 32-bit Oracle Client library cannot be loaded: "The specified module could not be found"

3
  • can you give details on what "doesn't work" means? error messages etc.? Commented Apr 11, 2018 at 9:52
  • cx_Oracle.DatabaseError: DPI-1047: 32-bit Oracle Client library cannot be loaded: "The specified module could not be found" i suspect maybe i am trying to establish connection wrongly ! Commented Apr 11, 2018 at 9:55
  • The message is pretty clear: you need to install the 32-bit Oracle Client libraries (somehow) to continue. cx_Oracle requires these client libraries in order to be able to connect to Oracle Database. (If you have 64-bit Python, you would need the 64-bit Oracle client libraries). Commented Apr 11, 2018 at 22:57

2 Answers 2

2

You need to either (a) install the 32-bit Oracle Client libraries or (b) ensure that you are using 64-bit Python and 64-bit cx_Oracle. See the installation instructions for more information.

Sign up to request clarification or add additional context in comments.

Comments

0

Please check , 32 bit/ 64 bit library , and Installation Guide

Moreover, you can refer to the below code snippet

    from __future__ import print_function
    
    import cx_Oracle
    import boto3
    import base64
    import requests
    import json
    import configparser
    
    def connect_oracle(oracle_arn,oracle_host,oracle_port,oracle_db):
        session = boto3.session.Session()
        client = session.client('secretsmanager','us-west-2')
    
        response = client.get_secret_value(SecretId=oracle_arn)
        data = json.loads(response['SecretString'])
    
        dsn_tns = cx_Oracle.makedsn(oracle_host,oracle_port,oracle_db)
    
        conn = cx_Oracle.connect(data['username'],data['password'],dsn_tns)
    
        return conn
    
    
    
    def test_oracle_connect():
    
        #change the variable value as required 
        oracle_arn = 'oracle_arn'
        oracle_host = 'oracle_host'
        oracle_port = 'oracle_port'
        oracle_db = 'oracle_db'
        
        run_rds_test_scripts = 'true'
    
        if run_rds_test_scripts == 'true':
            conn = connect_oracle(oracle_arn,oracle_host,oracle_port,oracle_db)
    
            cur = conn.cursor()
            executed = cur.execute('select count(*) from dba_tables')
            res = cur.fetchmany(numRows=1)
    
            row_number = len(res)
    
            assert row_number == 1
            cur.close()
            conn.close()
        else:
            print('no run')

test_oracle_connect()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.