SATYAM SAREEN
SATYAM SAREEN

Reputation: 41

not able to work with cx-oracle

I am new to python and oracle, I have written the code for the connection to oracle database 11g but it gives an error:

import cx_Oracle
    con=cx_Oracle.connect('sys/Satyam123@localhost/xe')
    con.close(

)


It gives the following error in pycharm:

C:\Users\DELL\venv\module2\Scripts\python.exe C:/Users/DELL/Desktop/PYTHON/module2/check.py Traceback (most recent call last): File "C:/Users/DELL/Desktop/PYTHON/module2/check.py", line 2, in con=cx_Oracle.connect('sys/Satyam123@localhost/xe') cx_Oracle.DatabaseError: DPI-1047: 32-bit Oracle Client library cannot be loaded: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help

Upvotes: 1

Views: 3696

Answers (3)

Sachin
Sachin

Reputation: 1704

It seems like,there is issue related to PATH.You can try to install package with the IDE terminal.In your case just try to install a package with pycharm terminal.

After that try to execute below script:

import cx_Oracle
import db_config
user="test"
pw="test"
dsn="localhost:port/TEST" #here TEST is service id

con = cx_Oracle.connect(user, pw, dsn)

cur = con.cursor()
cur.execute("select * from test_table")
res = cur.fetchall()
for row in res:
    print(row)

Still having an issue then you can refer :

[https://oracle.github.io/python-cx_Oracle/samples/tutorial/Python-and-Oracle-Database-Scripting-for-the-Future.html]

Upvotes: 0

swarupmishal
swarupmishal

Reputation: 55

I had the same issue. Please follow the link https://oracle.github.io/odpi/doc/installation.html and install Oracle Instant Client 64-bit or 32-bit as per your system version. Once this is installed python would automatically be able to find Oracle Client libraries and you can successfully connect to the database.

Upvotes: 0

Bjarte Brandt
Bjarte Brandt

Reputation: 4461

Please download and install Oracle Client. (There are several editions of Oracle Client, but the instant one will do):

http://download.oracle.com/otn/nt/instantclient/122010/instantclient-basic-nt-12.2.0.1.0.zip

Once it is installed, the cx_Oracle python module will look for the Oracle libs (OCI) and load them.

Upvotes: 1

Related Questions